This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: problem with sizeof struct alignment


20 in hexadecimal is 32 in decimal.   
   
-----Original Message-----
From: Andrew Hill [mailto:dru@treshna.com]
Sent: 19 November 2003 12:57
To: cygwin@cygwin.com
Subject: problem with sizeof struct alignment

I have this struct

typedef struct {
double arrival;
double departure;
char status;
int bookingid;
int userid;
} RoomStatus;

I'm using gcc with no compiler options or flags.  Under linux with gcc, 
sizeof(RoomStatus) returns me 28 - as i would expect. If I use a borland 
C++ compiler it also returns a sizeof 28. But with cygwin + gcc it 
returns a sizeof 32.  I'm a bit confused. Does cgwin + gcc align to 
nearest 8bytes for structs?  Is there a compiler option to tell it to 
use 4 byte alignment?  Is it just me whos having this problem?

I checked the sizeof for int, double and char and they all correct, 
changing the char to an int or specifically saying its a 4bit int 
doens't seem to make any difference.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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