Volatile is a qualifier in C, which is applied to a variable when it is declared. It is used extensively while writing programs for embedded systems, especially when dealing with hardware. Most often, Volatile variable usage stumps an embedded system programmer with unexpected outputs. What makes Volatile variables different? What are its instructions to the compiler? It tells the compiler that the value of the variable may change at any time during the execution of the code without the knowledge of the compiler. If proper precautions are not taken, the desired output may not be achieved. A variable should be declared volatile whenever its value may change unexpectedly.
Written by one of our mentors, January 2015 edition of Open Source For You (OSFY) is having an article titled ‘Volatile Demystified’ got published. Here is the URL to download the complete PDF version of the article: