1.

What Are The Uses Of The Keyword Volatile?

Answer»

Volatile keyword is used to prevent compiler to optimize a VARIABLE which can change unexpectedly beyond compiler's comprehension. Suppose, we have a variable which may be changed from scope out of the program, say by a signal, we do not WANT the compiler to optimize it. Rather than OPTIMIZING that variable, we want the compiler to load the variable every time it is encountered. If we declare a variable volatile, compiler will not cache it in its REGISTER.

Volatile keyword is used to prevent compiler to optimize a variable which can change unexpectedly beyond compiler's comprehension. Suppose, we have a variable which may be changed from scope out of the program, say by a signal, we do not want the compiler to optimize it. Rather than optimizing that variable, we want the compiler to load the variable every time it is encountered. If we declare a variable volatile, compiler will not cache it in its register.



Discussion

No Comment Found