Mail Archives: djgpp/1997/09/18/13:31:15
I'd try responding in my barely used french, but it would make even less
sense than my english...
Anyway, I don't know about french documentation, but volatile is another
keyword that can be tagged on variables. (like const, or static...)
However, the compiler really doesn't HAVE to do anything. VOLATILE is
compiler dependent. The usual usage is to indicate that a variable is
not just memory, but something like an I/O address. This way, if you
write:
*foo = 1234;
*foo = 5678;
The compiler might normally think this was dumb, and remove the first
statement. But with foo declared volatile, it (might) not optimize this,
thinking that assigning to foo twice could have a real effect. Also, it
goes the other way. The value could change at just about any time, so
reading the variable many times shouldn't be reduced to one access. I
had this exact same question this summer, and this was the explanation I
got, so I hope it's right.
Brian
- Raw text -