tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] a problem about pointer size


From: Simon 'corecode' Schubert
Subject: Re: [Tinycc-devel] a problem about pointer size
Date: Mon, 12 Nov 2007 10:22:13 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071022)

oohmail wrote:
> typedef struct A_TAG A;
> struct A_TAG
> {
> short type ; 
> long file; 
> ..........
> } ;
> 
> 
> A a ;
> A *p_a ;
> 
> p_a = &a ;
> 
> when &a address is 100 ,the sizeof a.type is 2 , so the p_a->file address 
> should be 100+2 = 102 ,but I found it is 104 ,

No, you are wrong.  The compiler adds two extra bytes as padding, so
that the 32bit field "file" is aligned on a 32bit boundary.

This is how all common compilers behave.

cheers
  simon


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]