GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


A Paste by Anonymous
/* ... */

#pragma pack(push)
#pragma pack(1)

struct struct_s
   {
   unsigned char b1;
   unsigned a : 6;
   unsigned b : 10;
   };

std::cout << sizeof( struct_s );

#pragma pack(pop)

/* ... */

 
Comments by GLProgramming users
 
Author Comment by Anonymous 14:17:38 23/Nov/2004 


    I was expecting the output to be 3 bytes, as in (6 + 10 + 8) / 8

but the answer was 5 , both the 6 bits and the 10 bits was packed to 1 byte. I wonder how to force them together... anyone?