I do some research and did not find a good answer, and I hope for a better understanding. I know how to use volatile , but you have a question about what it does when its placement is different in variable declarations, for example.
An integer designated as volatile , and when read / write to this memory location always goes into the memory location.
The pointer value is volatile and when read / write to this memory location always go to the memory location.
This is a subtle difference, but from what I can tell, the difference is in something like this.
volatile int * foo; int * volatile bar; volatile int testInt = 5; ------------------------ | 0x020 | - 0x000 (foo), memory location 0x000 can be cached. ------------------------ | 0x020 | - 0x010 (bar), memory location 0x010 can't be cached. ------------------------ | 5 | - 0x020 (testInt) ------------------------
My question is, for example, if a volatile quantifier is not a pointer type.
volatile int foo = 5; int volatile bar = 5; ------------------------ | 5 | - 0x000 (foo), memory location 0x000 can't be cached. ------------------------ | 5 | - 0x004 (bar), memory location 0x004 can't be cached. ------------------------
Don't these two ads do the same for pointers without pointers?
source share