This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

alignment


Hi,

I have a structure TCB which looks like this
struct TCB {
...
 struct IP_header out_ip_header;
 struct Pseudo  out_pseudo;
 struct TCP_header out_tcp_header;
...
};

sizeof(IP_header) = 20
sizeof(Pseudo) = 12
sizeof(TCP_header) = 20

And if i define variable of type TCB, slot out_ip_header begins for exmple
at address 0x804d0f2 and slot out_pseudo begins at 0x804d106 and
out_tcp_header at 0x804d114. It means, that there are 2 octets gap between
end of out_pseudo and begining of out_tcp_header. How can i get off this
gap? Is there any command line parameter of gcc? And why the gap is there?


The structure of  IP_header, Pseudo and TCP_header are below.

It's on I386 architecture.

Thanks
-Olda


struct IP_header {
 uint8_mt VER_IHL;
 uint8_mt TOS;
 uint16_mt LEN;
 uint16_mt ID;
 uint16_mt FFO;
 uint8_mt TTL;
 uint8_mt PROTO;
 uint16_mt checksum;
 uint8_mt source_addr[4];
 uint8_mt dest_addr[4];
};

struct Pseudo {
 uint8_mt source_addr[4];
 uint8_mt dest_addr[4];
 uint8_mt zero;
 uint8_mt PTCL;
 uint16_mt TCPL;
};

struct TCP_header {
 uint16_mt source_port;
 uint16_mt dest_port;
 uint32_mt SEG_SEQ;
 uint32_mt SEG_ACK;
 uint8_mt THL;
 uint8_mt control;
 uint16_mt SEG_WIN;
 uint16_mt checksum;
 uint16_mt urgent;
};

where

typedef unsigned char  uint8_mt;
typedef signed char int8_mt;

typedef unsigned short  uint16_mt;
typedef short   int16_mt;

typedef unsigned int  uint32_mt;
typedef int   int32_mt;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]