----
module main;
const char[] CT_STRING = "int i=0;";
void main(){
mixin( CT_STRING );
}
----
The string can be found in the executable.
Comment #1 by Marco.Leise — 2014-01-18T17:36:58Z
That is correct. that other module "use_CT_STRING.d" could import it. Its removal can only be done by whole program optimizations and or the external linker.
Have you tried actually declaring a compile time string like this?:
enum CT_STRING = "int i = 0;";
Comment #2 by pro.mathias.lang — 2018-10-22T03:59:21Z
Indeed, this is the correct behavior.
`static immutable` + initializer, or `static const` + initializer leads to a manifest constant which is an lvalue (you can take the address of it).
On the other hand, `enum` leads to an rvalue (much like a define, it is copy pasted everywhere).
Closing as INVALID.