core.sys.posix.unistd link error

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Sep 22 12:49:58 PDT 2013


22-Sep-2013 15:52, Ruslan Mullakhmetov пишет:
>
> I found where the problem is.
>
> I used a system call (external C function) in class ctor. then I
> declared global variable of this class and INITIALZIED that variable
> inplace. If i move initalization in module static this() everything
> compiles.
>
> the code is:
>
> incorrect version:
> http://dpaste.com/hold/1391530/
>
> correct:
> http://dpaste.com/hold/1391523/
>
>
> But now i need to sort out what the difference between
> // global scope
>
> int a = 10;
>

This just puts calculated value 10 into TLS data section as initializer 
for a.

> and
>
> int a;
>
> static this()
> {
>   a = 10;
> }
>

This defines a global with 0 initializer.

Then static this is a function that is executed for each D thread on 
creation, following the module dependency chain (i.e. if there is static 
this in imported module it should be run first).

I would be curious to see why you believe them to be the same.

> I appreciate if somebody give a link or chapter number where to read.


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list