I have 8 bytes string with flags, some of them are booleans and some are chars. What I want is access that flags by it's names in my code, like myStruct.value1
I created some struct according to my wishes. I would expect I can split the string into that struct as both have size of 64 bits in total.
// destination
typedef struct myStruct_t {
uint8_t value1 : 8;
uint8_t value2 : 8;
uint16_t value3 : 16;
uint8_t value4 : 8;
uint8_t value5 : 1;
uint8_t value6 : 1;
uint8_t value7 : 1;
uint8_t value8 : 1;
uint8_t value9 : 1;
uint16_t value10 : 11;
uint8_t value11 : 8;
} myStruct_t;
// source
char buf[8] = "12345678";
// read about strcpy and memcpy but doesn't work
memcpy(myStruct, buf, 8);
However it does not work and i get following error message:
error: cannot convert 'myStruct_t' to 'void*' for argument '1' to 'void* memcpy(void*, const void*, size_t)'
memcpy(myStruct, buf, 8);
^