d.f.s. wrote:
[..]
My understanding of 'volatile':
A key word which indicates that an object is likely to be
or WILL be modified. Redundant for objects not
declared const.
No, it's not.
Was used to help older compilers to
do optimization. Sort of like 'register', it is seldom used
or needed with modern compilers.
I assume that my understanding of 'volatile' is wrong.
Yes, but not entirely. 'volatile' indicates an object that can change
by means other than the program in which it appears. It could be some
address that a device (through a driver or DMA means) can update based
on a change of its state (serial port receives another input, etc.)
Declaring a variable 'volatile' makes the compiler generate code that
reads the value from the variable's storage any time it's needed in
an expression, precluding the compiler from caching the value or some
other optimization WRT the variable's value.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask