[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] HELP: __attribute__ ((packed)) confusion
From: |
Dave Dodge |
Subject: |
Re: [Tinycc-devel] HELP: __attribute__ ((packed)) confusion |
Date: |
Thu, 10 Feb 2005 11:28:03 -0500 |
User-agent: |
Mutt/1.4.2i |
On Thu, Feb 10, 2005 at 01:55:40AM -0800, Christopher Dobbs wrote:
[...]
> This structure as shown above, compiles under gcc at 512 bytes, but no
> matter what I try, I get 516 bytes under tcc.
For this code:
#define PACKED __attribute__ ((__packed__))
typedef struct { // 512 byte header
unsigned char PACKED bc[3]; // Boot Code Signature
unsigned char PACKED signature[8]; // signature string "LIBV10"
unsigned long PACKED dir; // offset of first dir block
unsigned long PACKED freechain; // offset of first block
unsigned long PACKED eof; // offset of end of freechain
unsigned char PACKED label[41]; // Volume Label
unsigned long PACKED attr; // Volume Attributes
char PACKED passcode[16]; // Volume Password
unsigned char PACKED fill[428]; // Filler
} header;
I get sizeof(header) as 512 under tcc 0.9.22. I have a couple of small
patches applied to tcc but they shouldn't affect packing/alignment.
If you're having problems, try printing the offsetof() each field and see
where it doesn't match the requested alignment.
-Dave Dodge