Const and enum optimizations
Phil Lavoie
maidenphil at hotmail.com
Thu Jan 3 07:58:11 PST 2013
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
More information about the Digitalmars-d-learn
mailing list