I have a header file which defines two objects:
// header.h
static A object1("param1", "param2");
static A object2("param1", "param2");
This is how A looks like:
class A {
public:
int random;
A(char* p1, char* p2){
printf("Called constructor for %s | %s\n", p1, p2);
}
};
However, the constructor is never getting called. I'm doing this:
#include "header.h"
int main(){
// to prevent optimization issues
object1.random = rand();
if (object1.random != 3) { printf("\n"); }
return 0;
}
And I never see the messages on the console, it just remains empty.
I've read about the static initialization order fiasco
, but I believe it's not the problem here, because neither of those objects is relying on the other one, so order doesn't really matter...
I'm using MSVC++ 2013 on Windows 7 x64