Hello Forum!
I am trying to understand what is the advantage of using volatile keyword in standard C. The volatile keyword in C language confuses me a lot. definition say that a volatile keyword indicates that the value of the variable can be changed from outside at any time. I often see that the volatile keyword is used inside interrupt service routine.
Let's say i have a c program in which I declare a global variable X. I initialize X with 0 in main function. But when an interrupt occurs, the value of this X changes.
What happens if I don't use volatile keyword in the program, will the compiler remember the current value of X if it has been modified by interrupt?
I am trying to understand what is the advantage of using volatile keyword in standard C. The volatile keyword in C language confuses me a lot. definition say that a volatile keyword indicates that the value of the variable can be changed from outside at any time. I often see that the volatile keyword is used inside interrupt service routine.
Let's say i have a c program in which I declare a global variable X. I initialize X with 0 in main function. But when an interrupt occurs, the value of this X changes.
What happens if I don't use volatile keyword in the program, will the compiler remember the current value of X if it has been modified by interrupt?