|ARM Technical Support Knowledge Articles|
Applies to: C166 C Compiler
Information in this article applies to:
Do the 'const' or 'volatile' keywords have any particular meaning to the C166 3.12 or 4.x compilers?
Declaring a variable as const is identical to declaring the variable without 'const', the only difference is that the compiler will warn you if you try to modify a const.
Consts are placed in the NCONST/FCONST/HCONST class depending on if they are near, far or huge respectively.
Declaring a variable as volatile ensures that it is not affected by the optimizer. For example, if you locate a variable called 'rtc' at the address for some memory-mapped hardware and you only ever write to that location, then the optimizer sees that you never do anything with the variable once initialized. It will be optimized out. Declaring the variable as volatile avoids that problem.
Article last edited on: 2004-06-09 15:25:14
Did you find this article helpful? Yes No
How can we improve this article?