May 2020
Intermediate to advanced
496 pages
13h 54m
English
Static memory's lifespan is the entire duration of a program. Global variables, as well as any variables declared inside functions using the static specifier, will be placed into static memory and they will have a lifetime equal to that of the program.
For example, both globalVar and staticVar are located in static memory and will persist for the entire lifetime of the program. The initialization of staticVar only occurs once during the initial program load:
uint8_t globalVar = 12;void myFunc( void ){ static uint8_t staticVar = 0; ...}
When variables are declared as static, memory is guaranteed to be available. All of the global and static variables defined by the program are placed into their locations during the linking phase. ...