Thread overview
[Issue 17747] extern(C) shared static module constructor should be called in betterC programs
August 12
https://issues.dlang.org/show_bug.cgi?id=17747

--- Comment #1 from Илья Ярошенко <ilyayaroshenko@gmail.com> ---
And extern(C++), extern(D) can/should work too.

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

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

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

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

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

--- Comment #3 from Илья Ярошенко <ilyayaroshenko@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.

--