Subject: Re: problem with sizeof struct alignment
From: "Demmer, Thomas" <[email-masked]>
To: "[email-masked]'" <[email-masked]>
Cc: "[email-masked]'" <[email-masked]>
Date: Wed, 19 Nov 2003 16:03:24 +0100

Andrew Hill <dru at treshna dot com> wrote

>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.

gcc -mno-align-double 
is your friend to achieve ABI compatibility. This mis-feature
was introduced with gcc-3.whatever. Search the mailing
list for a remark from Brian Ford giving a heads up on this problem.

Best regards / Mit freundlichen Grüssen,

Thomas Demmer
Kraft Foods R&D Inc.
Tel.: +49 (0)89 62738-6302
Fax: +49 (0)89 62738-86302

Thought of the day
Admiration, n.:
        Our polite recognition of another's resemblance to ourselves.
                -- Ambrose Bierce, "The Devil's Dictionary"

--
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/