“Andrzej Kocon” <ako@box43.gnet.pl> wrote in message
news:3b0cbf9f.8520041@inn.qnx.com…
On Wed, 23 May 2001 13:33:32 -0700, Mitchell Schoenbrun
maschoen@pobox.com> > wrote:
Previously, Bill Caroselli wrote in qdn.public.qnxrtp.porting:
Can you explain this a little more?
Sure,
Lets say you have some memory mapped hardware with the following
structure:
With the Watcom compiler you would create the following
structure.
struct
{
unsigned char function_A;
unsigned short value_A;
};
Now recompile this under GNU and you get the following
layout
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.
ako
I think the attribute((packed)) method is the
common way to remove padding from structures in GCC:
struct HDLCFrame_FS
{
unsigned char mLogicChan;
unsigned char mFlags;
unsigned long mTimeStamp;
unsigned char mData[0];
} attribute((packed));
\
Mats Byggmastar
http://www.multi.fi/~mbc