[Info-vax] yet another sys$qiow question
ergamenes at gmail.com
ergamenes at gmail.com
Wed Aug 19 15:09:14 EDT 2015
> Iteresting use of vocabulary. To me, "volatile" would imply that the
> variable can be optimized away or be temporarily allocated (aka: not
> garanteed to survive after end of subroutine).
volatile refers to the value of the variable. A volatile variable may have its value change without warning. So if you read three characters from your memory mapped serial IO port, you need to specify volatile otherwise the compiler may generate code that reads one character and assumes that the two others must be the same, or even reads no characters at all. Similar considerations apply with QIO where data can 'magically' appear in the buffer and IOSB.
Nothing has changed, except that compilers have got much better at optimizing, and CPUs have got a lot more complex. If you still think of C as a portable PDP-11 assembler, your intuition is likely to mislead.
More information about the Info-vax
mailing list