Module static constructor doesn't work?

Andrey Zherikov andrey.zherikov at gmail.com
Thu Aug 8 19:33:42 UTC 2019


On Thursday, 8 August 2019 at 16:04:33 UTC, a11e99z wrote:
> On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov 
> wrote:
>> I have the following code:
>>
>> // main.d
>> int main()
>> {
>>     import std.stdio;
>>     writeln("hello");
>>     return 0;
>> }
>>
>> But if I create library from lib.d first and then link it with 
>> main.d then ctor/dtor are not called:
>> $ dmd.exe -lib lib1/lib.d -od=lib1
>> $ dmd.exe main.d lib1/lib.lib && main.exe
>> hello
>
> try to add to main.d:
>> import lib1.lib;

Actually importing solved the issue although it's not ideal 
solution IMO. Thanks for your help!


More information about the Digitalmars-d-learn mailing list