Tech Support > Computer Hardware > Microprocessors > volatile attribute
volatile attribute
Posted by Gianluca Moro on December 6th, 2004


Hi,

the volatile attribute is an indication that the variable can change
for example on account of an interrupt.

With this indication the compiler cannot use a register to store the variable,
or do any type of optimization.

For example if a volatile variable is not used, the compiler do not
remove it, as it could be used by an interrupt

bye
giammy

Posted by Mark A. Odell on December 6th, 2004


giangiammy@yahoo.com (Gianluca Moro) wrote in
news:dbacaf5c.0412060744.729db90e@posting.google.c om:

Volatile is a keyword in C.

Or when you create a pointer to a volatile "thing" that is, in fact,
memory mapped hardware. If the hardware updates the "thing" and the
compiler knows the variable is volatile then things should work as you
expect. This is not a requirement of ISO C which specifies the behavior of
volatile variables in a very restricted way.

No, it can use a register but it must reload the register with the source
location every time you access the volatile variable.

That's a consequence of volatile.

--
- Mark ->
--


Similar Posts