9.4 Variables in Program Memory
The only variables that are placed into program memory are those that are
not auto
and which have been qualified const
. Any
auto
variables qualified const
are placed on the stack
along with other auto
variables.
Any const
-qualified (auto
or
non-auto
) variable will always be read-only and any attempt to write to
these in your source code will result in an error being issued by the compiler.
A const
object is usually defined with initial values, as
the program cannot write to these objects at runtime. However, this is not a requirement.
An uninitialized const
object is allocated space in the
bss
section, along with other uninitialized RAM variables, but is still
treated as read-only by the compiler.
const char IOtype = 'A'; // initialized const object
const char buffer[10]; // I just reserve memory in
RAM