“Andrzej Kocon” <firstname.lastname@example.org> wrote in message
On Wed, 23 May 2001 13:33:32 -0700, Mitchell Schoenbrun
email@example.com> > wrote:
Previously, Bill Caroselli wrote in qdn.public.qnxrtp.porting:
Can you explain this a little more?
Lets say you have some memory mapped hardware with the following
With the Watcom compiler you would create the following
unsigned char function_A;
unsigned short value_A;
Now recompile this under GNU and you get the following
Name Offset Size
Function A 0 1
Filler 1 1
Value A 2 2
Note that an extra byte has been inserted to give the
unsigned short an alignment of 2.
Is there a command line option to achieve QNX4 type alignment?
I haven’t found one yet. I’d be interested in knowing of it,
or a “pragma” if there is one.
The alignment in gcc (among other things) is described in
/usr/info/gcc.info-* files. It may be defined using variables’
attributes, or with different styles of pragmas. There are also
_pack*.h headers in /usr/include. I haven’t found any command
line option yet.
I think the attribute((packed)) method is the
common way to remove padding from structures in GCC:
unsigned char mLogicChan;
unsigned char mFlags;
unsigned long mTimeStamp;
unsigned char mData;