Unstable in C and Cpp in linux environment

I am writing a program for ARM with a Linux environment. this is not a low level program, say application level

Can you explain to me what is the difference between them,

int iData;

against

volatile int iData;

Does this have an effect on specific equipment?

+5
source share
1 answer

volatile in C appeared with the goal of not caching variable values ​​automatically. It will show the machine that it does not cache the value of this variable. Thus, every time he encounters this, he takes the value of this volatile variable from main memory. This mechanism is used because at any time the value can be changed by the OS or by any interrupt. Therefore, using volatile will help us access the value each time.

Wiki

-1

All Articles