I am trying to port c++ application to arm board with gcc tools (using RTOS). But my static const constructors are not being called.
Simple code:
class TestClass {
public:
TestClass();
TestClass(int m);
TestClass(const TestClass& other);
~TestClass();
int getM() const;
const TestClass& operator = (const TestClass& other);
private:
int m;
};
class TestInitClass {
static const TestClass TestClassObj;
};
const TestClass TestInitClass::TestClassObj = TestClass(5);
I provide class definitions. But when I call this with TestInitClass::TestClassObj.getM() it returns me 0.
There are multiple problems:
- My static const is getting allocated in .bss section. It is not getting in .ctors sections (this may be linker script problem?!)
- And even if it gets in .ctors section, how do I call these constructors
- When I use static c++ library how should I call them?
Thanks