Hallo, ich würde gerne ein Struct definieren, welches zwei Bytes mit Bitfeldern enthält. Leider funktioniert folgender Code nicht:
1 | typedef struct my_struct |
2 | {
|
3 | typedef struct |
4 | {
|
5 | char byte_1_bit_1_4 : 4, |
6 | byte_1_bit_5_8 : 4; |
7 | } byte_1; |
8 | |
9 | typedef struct |
10 | {
|
11 | char byte_2_bit_1_6 : 6, |
12 | byte_2_bit_7_8 : 2; |
13 | } byte_2; |
14 | } my_struct; |
15 | |
16 | my_struct test; |
17 | test.byte_2.byte_1_bit_1_4 = 12; |
Danke im Voraus!