I'm a little confused about the scenario - if it's that you want one particular access to a variable to be treated as volatile
, use
dest = *(volatile TYPE *)&src;
where TYPE is the type of src
. You may also need
asm volatile ("" ::: "memory");
in carefully controlled locations, to prevent the compiler from moving loads/stores of other memory locations across the volatile read.
Also investigate C11's _Atomic
types. (I'm not sure if GCC supports these yet.)