Comment on How to Think About Variables in CparentComments−dchichkov13yI think that your original suggestion - use memcpy is a better solution then volatile.It looks like the following code would work: #include <stdio.h> #include <stdint.h> void f(volatile uint32_t *x, volatile uint16_t *y) { *x = 5; printf("%d\n", *y); } int main() { volatile uint32_t x = 10; f(&x, (volatile uint16_t*)&x); } And the compiler is guarantied () to issue store op on x = 5 and consecutively load op on y, but the code is looking pretty ugly.() assuming no alignment problems
Comments
I think that your original suggestion - use memcpy is a better solution then volatile.
It looks like the following code would work:
And the compiler is guarantied () to issue store op on x = 5 and consecutively load op on y, but the code is looking pretty ugly.() assuming no alignment problems