How not to initialise a static variable with GCC

208 views Asked by At

I am programming a micro in C++. I need a static variable to survive across a reset.

The object is used to hold more detailed information about the reason for the reset. I can't be guaranteed that I can log it to flash at time of reset, so I need to log it after the reset.

I can use pointer constants and manually allocate a block of ram that is not given to the linker in the segments file.... and do in place initialisation.

But I was wondering is there a way of using attributes or something similar in gcc that will allow me to avoid static initialisation of a static variable. This makes it slightly more portable between the different micros I am using as I don't have to fiddle with the memory map manually.

I need the standard object constructors to work when the object is assigned explicitly.

0

There are 0 answers