[Interest] [Qt-interest] Calling qRegisterMetaType on static initialization

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Jan 25 01:21:42 CET 2012



Am 21.01.2012 um 15:06 schrieb Karl Krach <mailinglists at blueSpirit.la>:

> "Static member variables are initialized before the 'real program'
> (main()) starts" - right? 

IIRC when it comes to static variables defined in shared libraries: "It depends" - on the compiler/platform being used.

I think that was also the main reason why one should call "qInitResources" (a global function or a macro, can't remember) as soon as possible in the main function, to make sure that embedded data ("Qt resource compiler") defined in shared libs is really initialised.

Again, it might work with one compiler (I think with MSVC it does when embedding data into DLLs) without calling qInitResources, but might fail with another (probably older) compiler.


Cheers, Oliver

p.s. Btw the last time I asked a question in the c++ comp group (really years ago) related to "shared libs" I was told: "That's not part of the C++ standard, dude - go read the man pages of your compiler/linker!" ;)


More information about the Interest mailing list