Programming Language Features
C volatile Objects declared as volatile are omitted from optimization because their values can be changed by code outside the scope of current code at any time. The system always reads the current value of a volatile object from the memory location rather than keeping its value in temporary register at the point it is requested, even if a previous instruction asked for a value from the same object. So the simple question is, how can value of a variable change in such a way that compiler cannot predict. Consider the following cases for answer to this question. Global variables modified by an interrupt service routine outside the scope Global variables within a multi-threaded application https://www.geeksforgeeks.org/understanding-volatile-qualifier-in-c/ C storage classes there are four storage classes: automatic , register , external , and static . auto The scope of automatic variables is local to the block in which they are declared, inc...
Comments
Post a Comment