AnsweredAssumed Answered

Constructors of Global Variables Are Not Being Called

Question asked by Peter Barbara on Apr 4, 2017
Latest reply on Apr 5, 2017 by Peter Barbara

Any class that is instantiated in global space doesn't appear to call its constructor to initialise its member variables.

 

To reproduce:

* Start a new S32DS project

* Select MPC5777C (Not sure if this matters)

* Set language for all cores to C++

* Set the library for all cores to NewLib

 

Attached is the modifed main_z7_0.cpp that can reproduce the results. I am expecting both glob_val and local_val to be equal to 10 by the time the code gets to the for loop. But I am finding that glob_val is 0 and local_val is 10.

 

I am unable to use a pointer and initialise it in main.

 

Is there a configuration I am missing on the compiler/linker? Looking at the map file the crtbegin.o does not get linked in and I believe it has something to do with initialising this type of thing.

Original Attachment has been moved to: main_Z7_0.cpp.zip

Outcomes