[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 06:42:38 PDT 2017


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

ZombineDev <petar.p.kirov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC, C++
                 CC|                            |petar.p.kirov at gmail.com

--- Comment #2 from ZombineDev <petar.p.kirov at gmail.com> ---
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.

--


More information about the Digitalmars-d-bugs mailing list