Hi, I define a struct like below: typedef struct { unsigned type :6; unsigned delete :1; unsigned mask :1; }UnitType; I think the length of this struct is 1 byte, but to my surprise, the length are 2 bytes, in the list file it says: NAME CLASS MSPACE TYPE OFFSET SIZE ==== ===== ====== ==== ====== ==== UnitType . . . . . . . . . . . . . . . TYPEDEF ----- STRUCT ----- 2 type . . . . . . . . . . . . . . . . MEMBER ----- FIELD 0000H 6.0 delete . . . . . . . . . . . . . . . MEMBER ----- FIELD 0000H 1.6 mask . . . . . . . . . . . . . . . . MEMBER ----- FIELD 0000H 1.7 Is it right? If right, maybe somebody here can explain it to me. Thanks & Regards. Elias
It's 2 bytes because the unsigned int type (which you used) is 2 bytes long. Jon
Search the knowledgebase for "bitfield" - for example: http://www.keil.com/support/docs/928.htm This is just one of many reasons why bitfields are best avoided - search this forum for previous discussions of this subject.
Thanks.