Defining constant values in struct

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 16 17:49:56 PDT 2015


On 6/17/2015 6:17 AM, tcak wrote:
> As far as I known, when I define a string with enum and it is used at
> different parts of code, that string is repeated again and again in
> executable file instead of passing a pointer to string. So, using enum
> with string doesn't seem like a good idea.
>
The string is not repeated again and again in the *executable*. The 
compiler is smart enough to recognize the same string is used in 
multiple places. It will be placed in the data segment only once. It's 
no different than using a string literal.


More information about the Digitalmars-d-learn mailing list