In the C/C++ types this indicates that this value may be modified outside of its declared scope. For example, if you are working with a memory mapped value (like you may see working directly with memory mapped BIOS, or some very rudimentary systems type work [drivers & TSR's]), it is reasonable to assume that some other program, or even a different function may access and change the value stored at that location, requiring the compiled program to "double-check" the value every time it needs to read from that location, as opposed to using a register, or optimizing out the read completely.
The practical upshot of this, for those not doing absurdly low level / microcontroller type stuff, is that declaring a variable as volatile can remove some unwanted compiler optimization.
For example, if we wanted to implement our own version of UNIX usleep():
CODE
// usleep(N) in posix systems runs a time delay loop for N microseconds
// also does some other stuff regarding interrupts that are way beyond this
// example
void usleep(int a)
{
int b = 0;
while(b < a)
{
b++;
}
}
most modern compilers are smart enough to look at this and say (correctly) "it doesn't do anything, don't bother compiling / linking it", and optimize out all or most of the procedure, but with volatile:
CODE
void usleep(int a)
{
volatile int b = 0;
while(b < a)
{
b++;
}
}
the compiler would assume that something is behind the scenes tinkering with "b", and will compile the loop more or less as desired.
Hope this helps,
-Jerome