[Icc-avr] Module globals static?
David Brown
david_brown at hotpop.com
Wed Oct 24 02:45:23 PDT 2007
Bengt Ragnemalm wrote:
> Is a variable that is global in a module also automatically static? I
> think it is but if so, shouldn’t the strictly most correct way to define
> the globals also be as static?
>
>
Yes, global variables are statically allocated, meaning they have a
fixed address in memory (assigned by the linker) and exist throughout
the lifetime of the program.
You can think of the keyword "static" as having two distinct effects on
variables - it ensures that they have a statically allocated address,
and it ensures that they have the minimum possible scope. Thus all
file-level data and functions should be declared "static" unless you are
specifically defining global data or functions that should be available
from other files.
mvh.,
David
More information about the Icc-avr
mailing list