February 17, 2004 [Bug?] static constructors/destructors in library | ||||
---|---|---|---|---|
| ||||
I have a module that has static constructor and destructor. If I link my application with object file then everything is working ok (constructor and destructor are called as expected). But if I use lib to make library out of that module object file and then link my application with such a library then constructor and destructor are not called! I am using latest dmd and dm packages (dmd 0.79, dmc 8.38, lib 8.00n) for Windows. Here is small example of what I am doing (maybe I am doing something wrong since these are my first steps in D): --- a.d --- import b; void main() { printf("Done\n"); } --- b.d --- static this() { printf("constructor\n"); } static ~this() { printf("destructor\n"); } Now, if I make a.exe with dmd a.d b.d or even with dmd -c b.d dmd a.d b.obj everything is as expected. But if I use: lib -c test.lib b.obj (or equivalent lib test.lib /c +b,,) dmd a.d test.lib then application is linked without errors but when it is started constructor and destructor are not called - again without any errors! Regards, Marko |
July 17, 2004 Re: [Bug?] static constructors/destructors in library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marko Nikolic | The problem here is that there's nothing the linker sees that pulls in b.obj, since nothing in a.obj references it. |
Copyright © 1999-2021 by the D Language Foundation