Hi,
I have noticed that I can’t use global instance of class, like this :
// Global values
Class1 Instance1 (Arg1);
void Function (void)
{
Instance1->Method1(); // ERROR : Constructor of Instance1 has not been called.
}
I know that use of global value is not safe and should be avoid, but I really can’t change all of them.
It seems that constructors of global instances are not called.
I guess it have something to do with the -nostartfiles gcc option.
But when I remove it, the link fail because .jcr region can not be found int the linker script.
Unfortunately, this is the limitation when using C++ with Open AT apps.
Global instances must be dynamically created when the application starts, e.g. in the main function…
// Global values
Class1* Instance1;
void Function (void)
{
Instance1->Method1();
}
void mainTask (void) // any task entry point
{
Instance1 = new Class1(Arg1);
}