Re:Modern C
by tomjakubowski on Friday September 04, 2020 @02:09PM
(#24377425)
In standard C only constant values can initialize globals, so the value can be baked into the binary.
Re:Modern C
by brandmeyer on Friday September 04, 2020 @06:30PM
(#24379536)
"baked into the binary" covers a lot of ground. You've got to get the initial contents of .data initialized somehow. In a typical microcontroller that's a copy from flash to ram.
Also: run global initializers. Getting kinda fuzzy on the boundaries, but I'd also add in the process to copy the initial contents of the .data segment from read-only to read-write storage.