CT usage only in executable
Daniel Murphy
yebblies at nospamgmail.com
Fri Jul 16 07:25:35 PDT 2010
"strtr" <strtr at sp.am> wrote in message news:i1lro6$307u$1 at digitalmars.com...
> == Quote from bearophile (bearophileHUGS at lycos.com)'s article
>> strtr:
>> > Not that the memory is really significant compared to the rest of my
>> > program,
>> > but I have a few fairly large arrays I use only in compile time and I
>> > was
>> > wondering why dmd still includes those in the executable (simple text
>> > search
>> > dug them up).
>> Are you able to create a smallish test case?
>> Bye,
>> bearophile
>
> ----
> module main;
>
> const char[] CT_STRING = "int i=0;";
>
> void main(){
> mixin( CT_STRING );
> }
> ----
> The string can be found in the executable.
>
I think if you use enum instead of const/immutable the compiler is not meant
to put them in the executable (it might anyway in some/all cases).
eg.
module main;
enum CT_STRING = "int i=0;";
void main(){
mixin( CT_STRING );
}
More information about the Digitalmars-d-learn
mailing list