how to Pack structure ?

Hi,

I would like to pack a structure

i tried

typedef struct {
char var1
float var2
int var3
}MypackedStruct attribute((packed));

but seems to do anything better than without the attribute.

I run QNX6RTP with qcc

Any idea ?

Yasmine <y.leroux@nospam.actris.com> wrote:

Hi,

I would like to pack a structure

Take a look at /usr/include/_pack*.h

-David


i tried

typedef struct {
char var1
float var2
int var3
}MypackedStruct attribute((packed));

but seems to do anything better than without the attribute.

I run QNX6RTP with qcc

Any idea ?


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Yasmine <y.leroux@nospam.actris.com> wrote:

Hi,

I would like to pack a structure

i tried

typedef struct {
char var1
float var2
int var3
}MypackedStruct attribute((packed));

The attribute is in the wrong place, it should be associated with the
structure, not the type name.

} attribute((packed)) MypackedStruct;


cburgess@qnx.com

Try “-fpack-struct” on the command line. Packs everything.


Randy Aeberhardt
<raeberhardt@tantalus-systems.com>
<www.tantalus-systems.com>

“Yasmine” <y.leroux@nospam.actris.com> wrote in message
news:aait87$hs6$1@inn.qnx.com

Hi,

I would like to pack a structure

i tried

typedef struct {
char var1
float var2
int var3
}MypackedStruct attribute((packed));

but seems to do anything better than without the attribute.

I run QNX6RTP with qcc

Any idea ?

You could also take a look at #pragma pack().

Try “-fpack-struct” on the command line. Packs everything.


Randy Aeberhardt
raeberhardt@tantalus-systems.com
www.tantalus-systems.com

“Yasmine” <> y.leroux@nospam.actris.com> > wrote in message
news:aait87$hs6$> 1@inn.qnx.com> …
Hi,

I would like to pack a structure

i tried

typedef struct {
char var1
float var2
int var3
}MypackedStruct attribute((packed));

but seems to do anything better than without the attribute.

I run QNX6RTP with qcc

Any idea ?
\

Jeff Baker <jbaker@qnx.com> wrote:

You could also take a look at #pragma pack().

Yes, -fpack-struct is a big 5lb sledge hammer. I am workng on a
fairly large project with a common makefile, and lots of inter
process communication. When we added -fpack-struct for communication
to the uControllers, and wierd things started to break, IIRC, the
resource manager app started and the UI app developed very interesting
issues. Escpecially the Photon app!

We now use

#define PACK attribute((packed))

and

typedef struct PACK
{
…stuff…
}

for the structures that require packing.

I guess th big difference is where the attribute is located. Try
moving it before the members.

Tom

i tried

typedef struct {
char var1
float var2
int var3
}MypackedStruct attribute((packed));

but seems to do anything better than without the attribute.

I run QNX6RTP with qcc

Any idea ?