[Ilugc] Structure alignment & Internal Padding

  • From: p_mdriyaz@xxxxxxxxxxx (Mohammed Riyaz)
  • Date: Mon Aug 14 09:10:04 2006

Hi,

now what is int:a? Is it some way related with bits? the size of the
 > structure is 12 in linux systems.Thanks for help.

This struct

struct x
{
char a;
int b;
};

would be 8 bytes in size(due to padding). 
I am just guessing that the compiler would internally convert this to

struct
{
char a:8;
int:24;
int b;
};

(Try compiling this, you will get an 8 byte structure)

You cant access those 24 bits bcos they are unnamed. 
(ofcourse you could use casts to get to those bytes, but thats not what
we are discussing here)

Regards,
Mohammed Riyaz

-- 
http://www.fastmail.fm - Choose from over 50 domains or use your own

Other related posts: