Binary Size: function-sections, data-sections, etc.

Kagamin spam at here.lot
Wed Dec 21 11:13:19 PST 2011


> Turned out not to be a good idea, as the compiler silently 
> accepts
> "shared private static this() {...}" and does not emit the dead 
> code anymore.
> But.. this constructor is run together with the un-shared ones, 
> ie possibly
> _after_ them... (this is not section-gc specific, happens w/o 
> it too)

try `private shared static this()`
AFAIK static ctors have some attribute ordering issue.

> import std.stdio;
>
> /* gcfuncdata2.d is a copy of this module, w/o main() */
> import gcfuncdata2;
>
> auto p(S...)(S args) { return stdout.writeln(__FILE__~": ", 
> args); }
>
> void main(string[] args){ p("main"); }
>
> static this() { p("ctor1"); }
> static this() { p("ctor2"); }
> shared static this() { p("shared ctor1"); }
> shared static this() { p("shared ctor2"); }
>
> static ~this() { p("dtor1"); }
> static ~this() { p("dtor2"); }
> shared static ~this() { p("shared dtor1"); }
> shared static ~this() { p("shared dtor2"); }
>
> unittest { p("unittest1"); }
> unittest { p("unittest2"); }

Also add class static ctors and function static variables.


More information about the Digitalmars-d mailing list