Jump to content
Sign in to follow this  

volatile key word

Recommended Posts

I was very surprised that "volatile" key word is not supported


it is use in other compiler to specify that a variable can

be modified at any time (in interrupt particulary) and so

when a test use this variable, the test must be performed

even if you write things like that :

unsigned char test; // global variable




test =1;



if (test==0) portb=0;



normally a compiler like GCC will optimise and don t create assembler code for last instruction that is never reach.

but if you specify that your variable is volatile

even if you are in high optimization level, the test will be performed (just imagine that your interrupt is use

to force test =0;)



is it possible that this keyword appear in next version of compiler

Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...