"volatile" tells the compiler, that the variable might change, even if th=
program does not change it. This may happen with variables changed by oth=
threads, interrupt service routines or variables representing some hardwa=
register. This information is importand for optimization, because during
optimization, the compiler assumes that variables keep the value assigned=
The meaning of static depends on the context. In C and C++ a local variab=
(a variable declared inside a function) declared as static is guaranteed =
keep its value between function calls. Technically, a local static variab=
is implemented like a global variable, but is only visible to the functio=
declaring the variable.
If you declare a global variable as static in ANSI-C, this ha no effect,
because global variables are by default static in ANSI-C. In C++, "static=
is the opposite of "extern". In C++ a global static variable is not visib=
outside the compilation module (=3D .cpp source file), in which the varia=
is defined. This means, that you may have a static global variable with t=
same name in every .cpp file without having the linker complain about thi=
I hope this helps.
[mailto:sdcc-user-admin@... Auftrag von
Gesendet: Sonntag, 5. August 2001 08:22
Betreff: [Sdcc-user] clarification, please
I'm a bit confused about the difference between'volatile','static',& one
no such declaration. This regards bits as well.
So far I have not used these declaration in my application.
Could someone clarify this to me?
Sdcc-user mailing list