www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Run code before dub dependency's `shared static this()`

reply Vladimirs Nordholm <v vladde.net> writes:
Hello.

I have dub dependency which has a `shared static this()`.

In my project, can I run code code before the dependency's 
`shared static this()`?
May 05 2019
next sibling parent Eugene Wissner <belka caraus.de> writes:
On Sunday, 5 May 2019 at 08:24:29 UTC, Vladimirs Nordholm wrote:
 Hello.

 I have dub dependency which has a `shared static this()`.

 In my project, can I run code code before the dependency's 
 `shared static this()`?
"Static constructors within a module are executed in the lexical order in which they appear. All the static constructors for modules that are directly or indirectly imported are executed before the static constructors for the importer." Source: https://dlang.org/spec/class.html#static-constructor
May 05 2019
prev sibling parent reply Daniel N <no public.email> writes:
On Sunday, 5 May 2019 at 08:24:29 UTC, Vladimirs Nordholm wrote:
 Hello.

 I have dub dependency which has a `shared static this()`.

 In my project, can I run code code before the dependency's 
 `shared static this()`?
This might work: pragma(crt_constructor) extern(C) void early_init() { }
May 05 2019
parent Jacob Carlborg <doob me.com> writes:
On 2019-05-05 14:52, Daniel N wrote:

 This might work:
 
 pragma(crt_constructor)
 extern(C)
 void early_init()
 {
 }
Keep in mind that the D runtime is not full initialized at this point. -- /Jacob Carlborg
May 06 2019