This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Data alignment with gcc
- To: Tim Jackson <tim at timj dot co dot uk>, gcc-help at gcc dot gnu dot org
- Subject: Re: Data alignment with gcc
- From: "Lewin A.R.W. Edwards" <larwe at larwe dot com>
- Date: Thu, 29 Mar 2001 22:00:23 -0500
>For reasons that I won't go into to keep this mail brief, it is essential
>that the class data members are in the order given above and most
>importantly *NOT* aligned to word boundaries. (essentially, an object is
Very common requirement for embedded systems and device drivers, at least
for structures. I don't know about C++ classes (embedded work in C++ is
relatively rare... and there are a lot of hidden implicit things in a C++
class :) But for structures, the following is an illustration of the
correct syntax:
// Master Boot Record
typedef struct {
unsigned char fill[0x1be]; // boot code
PARTENTRY partitions[4]; // partition table
unsigned char sig_55; // 55h boot signature
unsigned char sig_aa; // AAh boot signature
} __attribute__((packed)) MBR, *PMBR;
Works in 2.95.2.
=== Lewin A.R.W. Edwards (Embedded Engineer)
Work: http://www.digi-frame.com/
Personal: http://www.zws.com/ and http://www.larwe.com/
"Und setzet ihr nicht das Leben ein,
Nie wird euch das Leben gewonnen sein."