+ 19
What is the use of volatile keyword in c++?
1 Réponse
+ 2
It says compiler not to optimize somethig. It is good to use volatile variables when program itself doesn't use those variables, but something from outside uses them.
So if you have
int x = 1
while(x == 1)
....
It gets optimized to while(true). You can forbid this by using
volatile x = 1