10.2 Variables in Data Memory
Most variables are ultimately positioned into the data memory. The
exceptions are non-auto
variables which are qualified as
const
, which are placed in the program memory space, see 9.9.1 Const Type Qualifier.
Due to the fundamentally different way in which auto variables and
non-auto
variables are allocated memory, they are discussed
separately. To use the C/C++ language terminology, these two groups of variables are
those with automatic storage duration and those with permanent storage duration,
respectively.
static
variable defined outside a function has scope only in that
file, so it is not globally accessible, but it can be accessed by more than one function
inside that file, so it is not local to any one function either. In terms of memory
allocation, variables are allocated space based on whether it is an
auto
or not, hence the grouping in the following sections.