---
In UTTARA@yahoogroups.com, "lc_girish" <lc_girish@...> wrote:
>
>
Hi Uttarait's
>
[..]
>
>
* explain in detail where exactly volatile variables are used
>
The
common understanding is that volatile tells the compiler it must not do certain
optimizations. It means that the compiler must not optimize access to any
variable that is declared volatile, even if the compiler knows that its value
has not been changed between the last write access and the current read access.
Example:
int i=0; ... // i remain unchanged if (i==0) // compiler knows i is 0 here { ... }
Compiler
knows that i must be 0 because there was no write access since it was
initialized and it was not passed to any function that might have modified it. Hence a good compiler would optimize away the
actual access to the memory location that represents variable i. Exactly this optimization is disabled for a volatile
variable.
Additionally,
for a note on volatile qualifier use in function parameters, please see the
section 2.2.2.2 in http://oocities.com/vijoeyz/articles/c/pna/
Best,
Vijay
Zanvar