Hi,
I have a static array of structs, and I'd like to initialize it to 0. On C89 there is the universal initializer {0}, that sets the full array, even if using structs, to 0.
Is there some other way, like some kind of:
REPEAT num_items
{ 0, ... , 0 },
ENDR
That I could use instead? I'd prefer not to have to do an initialize() method for the class only for zeroing that array at beginning.
C89 universal initializer {0}
Re: C89 universal initializer {0}
Uninitialised static data is placed in the bss section which is by default initialised to 0.
-
- Member
- Posts: 71
- Joined: Sun Apr 01, 2018 4:02 pm
Re: C89 universal initializer {0}
OK so I remove the init then.
If I specify the section i.e. in code is also initialized to 0 or it gets the data that was already in that memory location?.
If I specify the section i.e. in code is also initialized to 0 or it gets the data that was already in that memory location?.
Re: C89 universal initializer {0}
So somewhat bizarrely, {0} is already supported for auto variables. I'm adding support for static variables at the moment so that should be in the next build as well.