I would be curious to see why you believe them to be the same.
Cause i'm a C++ programmer and there is no such thing as module
and module initializer, in fact object file initialization
consist of initialization of all its static variables somewhen
before the first call of a function in that object file (if any).
On Sunday, 22 September 2013 at 19:50:14 UTC, Dmitry Olshansky
wrote:
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.