[Issue 17747] extern(C) shared static module constructor should be called in betterC programs

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 13 21:35:47 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17747

--- Comment #3 from Илья Ярошенко <ilyayaroshenko at gmail.com> ---
(In reply to ZombineDev from comment #2)
> AFAIK, C doesn't have static constructors, only C++ has, so your example
> should be:
> 
> extern(C++) shared static this()
> {
>     // ...
> }
> 
> Of course extern (D) should work too:
> 
> extern(D) shared static this()
> {
>     // ...
> }
> 
> I'm not sure if `pragma(mangle, ...) [shared] static this()` should be
> allowed as static constructors / destructors are meant to be called only
> once and only by the runtime.

__attribute__ ((constructor)) is in C. It can be called in start before main,
without DRuntime.

--


More information about the Digitalmars-d-bugs mailing list