2013/10/16

"volatile" in c programming

Quick and dirty summery
"volatile" is a keyword to force compile to fetch a variable's value from memory every-time it reads this variable during the variable's life time.

Dig deeper
Since there maybe optimizations on the C compiler (maybe true or not), compiler will cache the value of a variable if there are no obvious side effects on that variable. "volatile" is a keyword to tell compiler not to do optimization on that variable.



Reference:
http://cboard.cprogramming.com/c-programming/73163-volatile-keyword.html

沒有留言:

張貼留言