dmd 1.063 and 2.048 release

Michal Minich michal.minich at gmail.com
Wed Aug 11 09:29:40 PDT 2010


Module constructor is not called when it is placed in imported module, 
and WinMain is used.


module hello;

import core.runtime;
import std.c.windows.windows;
import std.stdio;
import a;

extern (Windows)
int WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
    int result;

    void exceptionHandler (Throwable ex) { throw ex; }
	
    Runtime.initialize(&exceptionHandler);

    result = myWinMain();

    Runtime.terminate(&exceptionHandler);

    return result;
}

int main ()
{
   writeln (i1); // <---------------- prints "1" wich is ok.
   writeln (i2); // <---------------- prints "0" wich is incorrect.
   return 1;
}


/------

module a;

int i1 = 1;
int i2;

static this () {

    i2 = 2;
}


More information about the Digitalmars-d-announce mailing list