typedef struct { union { unsigned char FACULT : 1, NOT_ATTRIB : 4, VARTABLE : 1, VAR : 1, VALUE : 1; unsigned char bit_field; } container; union { unsigned char NOT_ATTRIB : 1, CANAL : 1, STRING : 1, BOOLEAN : 1, FLOAT : 1, S32 : 1, S16 : 1, U8 : 1; unsigned char bit_field; } type; } GFA_lib_Param;
Je tests ma structure de cette façon:
printf("%d - %d\n", (short)params[j].container.bit_field, (short)params[j].type.bit_field); printf("%d - %d\n", (short)params[j].container.VAR, (short)params[j].type.U8);
J'obtiens comme affichage:
2 - 15
0 - 0
Je ne comprend pas pourquoi j'obtiens 0 - 0 alors que je devrais obtenir 1 - 1.
Est-ce la structure mal rédigée? Ou une mauvaise utilisation. Bref comment résoudre ce pb?