Creating DLL

Adam D Ruppe destructionator at gmail.com
Thu Jun 16 16:32:28 UTC 2022


On Thursday, 16 June 2022 at 16:19:22 UTC, Ali Çehreli wrote:
> pragma (crt_constructor)

You have to be pretty careful about this since it might not run 
in the order you expect. If there's two things in the program 
with a equal-priority crt constructor, they are run in arbitrary 
order. In a shared lib, there's also the possibility that loader 
locks are in place, and if it runs rt_init specifically, that can 
run D module constructors... which might load other libraries.

Similar concerns apply to doing rt_init in DllMain.

This is why an explicit initialization call is the preferred 
method - there, the time it is called is well-defined by the user 
after initial loading is complete.


More information about the Digitalmars-d-learn mailing list