I have a cross platform library that has strange problem only on iPhone and only under release.
// .h
class cColor
{
public:
static const cColor Red;
static const cColor Green;
static const cColor Blue;
u8 r;
u8 g;
u8 b;
u8 a;
inline cColor(...) : ... { }
};
// .cpp
const cColor cColor::Red(0xFF, 0x00, 0x00);
const cColor cColor::Green(0x00, 0xFF, 0x00);
const cColor cColor::Blue(0x00, 0x00, 0xFF);
It does look like an initialization order fiasco but the problem is not in a static method but later in the program. All cColor::Red, Green, Blue are set to 0. Actually I put some printf inside the constructor's { } and it doesn't print anything but maybe it is OK since it's during globals initialization.
Now the worst part: The library was working in Release as well till recently before I added a few functions (200-300 lines) Objective-C code that doesn't even get executed. Just by cutting from the code size I can fix the issue but that is not really option for me. Also the application is not that big, memory can't be the problem.
Btw cColor is included in precompiled header in the library and later in the application that uses the library.
Help! I'm really out of ideas.
Edited: Here is more info...
I moved only the initialization code from the library to my application and now the constants are getting initialized correctly.
I really think that the linker is messing up something.
Any ideas?