|
|
|
|
|
by dchichkov
4802 days ago
|
|
I 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 |
|