Hi,
gcc 3.4.4
ld 2.17.50
When linking against c++ library, static member constructors aren't called before main(), neither for static nor for dynamic linking.
The strange thing here is that it works fine when the library is built on Cygwin with the same compiler/linker.
I 'm not an expert, but it seems to be mingw runtime issue.
Logged In: YES
user_id=11494
Originator: NO
Testcase please.
Danny
Logged In: YES
user_id=1779125
Originator: YES
File Added: static.tgz
Logged In: YES
user_id=11494
Originator: NO
The reason that the ctor is not invoked by the app is that the object containing the ctor is not linked in. Look at output of 'nm main.o'.
To force it to be linked in you could add a non-inline ctor to class Outer, eg
class Outer
{
public:
Outer();
private:
static Inner inn;
};
and define
Outer::Outer(){};
in the library module s.cpp