www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2673] New: Static constructors sometimes do not run when compiling with -lib

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2673

           Summary: Static constructors sometimes do not run when compiling
                    with -lib
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: bugzilla digitalmars.com


Tom S. writes:

This one still has problems.

---- Main.d:
import Mod;

void main() {
    foo();
}
---- Mod.d:
import Mod2;

extern (C) int printf(char*, ...);

void foo() {
    foo2();
}

static this() {
    printf("Running a static ctor for Mod"\n);
}
---- Mod2.d:
extern (C) int printf(char*, ...);

void foo2() {
}

static this() {
    printf("Running a static ctor for Mod2"\n);
}
----

Compiling these modules as:
dmd -c Main.d
dmd -lib Mod.d Mod2.d
dmd Main.obj Mod.lib
... and running Main.exe yields:
Running a static ctor for Mod


-- 
Feb 17 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2673


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla digitalmars.com  2009-03-11 14:53 -------
Fixed dmd 1.041 and 2.026


-- 
Mar 11 2009