77f Subj : Re: bit field bug? To : borland.public.cpp.borlandcpp From : "Jeff" Date : Mon Nov 17 2003 12:24 pm Thanks for all of your feedback... byte alignment is set to 1 byte. That is not the problem... I am aware of the pitfalls of bitfields... and the compiler dependent way they are used... but this is more a bug than a compiler dependent usage: Some more details: A structure that should be 15 bytes long is buily by BC 5.01 to be 16 bytes long... a single pad byte is being inserted after on of my bitfields: BYTE iOne : 6; BYTE iTwo : 2; pad byte is being put in here Interestingly enough, if I insert a dummy field so I can check the offsets of each bitfield: BYTE iOne : 6; BYTE iTwo : 2; char pcTemp[]; .. .. the extra byte goes away and now the structure is the 15 bytes it is supposed to be. f I remember correctly a while back, I read something about a situation where Borland C++ inserted blank padding bytes between bitfield elements for no reason... I just need to find that document or figure out the ryme or reason so I can get the alignment right... Thanks, Jeff "Andrue Cope" wrote in message news:VA.00001ff5.00be2c15@email.address.sorry... > Jeff, > > > The app uses bitfields in data structures > > > > Arrrrrggghh! > > Bitfields should be avoided as if they were the spawn of the Devil > ]:-) > > The C++ standard has never bothered to specify how the bits are to > stored. It is implementation specific. I can tell you now that > different Borland compilers store them differently so trying to > compile code from another vendor's compiler is really asking for > trouble. > > I would: > > 1.Get rid of the bitfields. > 2.Give the developer who used them a bit of a kicking or at least a > talking to. > > -- > Andrue Cope > [Bicester, UK] > . 0