Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Last active July 15, 2016 05:40
Show Gist options
  • Select an option

  • Save kkabdol/5dfb1ddcfc8c52ba60246f28bf21afe3 to your computer and use it in GitHub Desktop.

Select an option

Save kkabdol/5dfb1ddcfc8c52ba60246f28bf21afe3 to your computer and use it in GitHub Desktop.
volatile keyword
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