www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Release binary

reply Vladimir Voinkov <voinkovv gmail.com> writes:
I've noticed that constant strings are still presented in release bynary:

static invariant string Abc0 = "abcdefg";
static const string Abc1 = "abcdefg";

A source compiles with -O -release and the strings are not referenced. Is
linked able to optimize them out?
Jul 10 2009
parent Don <nospam nospam.com> writes:
Vladimir Voinkov wrote:
 I've noticed that constant strings are still presented in release bynary:
 
 static invariant string Abc0 = "abcdefg";
 static const string Abc1 = "abcdefg";
 
 A source compiles with -O -release and the strings are not referenced. Is
linked able to optimize them out?
No, the DMD linker isn't smart enough. (Maybe the LDC one is?) BTW that's why D2 has 'enum' for manifest constants. It's a language hack to work around a linker limitation.
Jul 13 2009