Last active
July 15, 2016 05:40
-
-
Save kkabdol/5dfb1ddcfc8c52ba60246f28bf21afe3 to your computer and use it in GitHub Desktop.
volatile keyword
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() | |
| { | |
| // 'non_volatile_int == 1' will be optimized to be 'true' by compiler | |
| int non_volatile_int = 1; | |
| while( non_volatile_int == 1 /* true */ ) | |
| { | |
| // code | |
| } | |
| // 'volatile_int == 1' won't be optimized by compiler | |
| volatile int volatile_int = 1; | |
| while( volatile_int == 1 ) | |
| { | |
| // code | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment