I have a const
variable in my embedded C program. It's defined and initialized with 0
in program code. It's placed in a special ROM area via linker script. One can change the content of the special area via special programming procedure, but it cannot be changed during main program execution.
The question is whether I have to declare the constant as volatile
. If it's not marked as volatile
, is the compiler allowed to replace all references to it with 0
? Or is it obligated to load it at least once during program execution?