I am wondering how efficient / is working the volatile declaration. In the following code:
volatile char var1 = * (volatile char *) 0x2000000;
printf("%d \n", var1 + 1);
It means that every time I am using the variable "var", it will be loaded from the address memory 0x2000000, but is the volatile cast of a fixed address necessary, or is it only to fit the type of var1?
Does this means that every time "var1" is read, it is read from memory, and not from a potential cached value? So in this code, we access two times the address 0x2000000?