We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
There is an SRC variable of 16 bits, how to create two 8-bit variables, so that one is addressed to the upper part and the second to the lower part of the SRC variable? type construction
uint16_t src; uint8_t b1 = * ((uint8_t *) & src); uint8_t b2 = * (((uint8_t *) & src) +1);
should work but at compilation produces:
MAIN.c (16): error: # 28: expression must have a constant value uint8_t b1 = * ((uint8_t *) & src); MAIN.c (17): error: # 28: expression must have a constant value uint8_t b2 = * (((uint8_t *) & src) +1); MAIN.c: 0 warnings, 2 erros
How to correctly address the variables B1 and B2 that, when changing these variables, the corresponding value in the SRC variable and vice versa change. Sorry for my english :)