Hi,

I have a question concerning compiler optimizations and their likelihood for const vs. enum declarations.

I came across some code recently that had a bunch of const declarations that were extracted from a C header. In this very header, those definitions are in fact #define clauses.

I was under the impression that those should be translated as:
header.c:
#define MY_CONST 1
...
module.d:
enum {
  MY_CONST = 1
}
and not:
module.d:
const MY_CONST = 1;

I thought that MY_CONST enum is more likely optimized since its address cannot be taken? But my real question is this: is a declaration like MY_CONST (enum) always optimized space wise (for dmd)? What is the likelihood of MY_CONST (const) being optimized as well?

Thanks!
Phil

Reply via email to