Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to override -fpack-struct ?

53 views
Skip to first unread message

irotas

unread,
Dec 7, 2009, 12:28:17 PM12/7/09
to
Hi,

I have a rather large project that heavily depends on structure
packing using -fpack-struct. I would estimate several dozen structures
that absolutely must be packed in order for the software to work
properly.

Today I encountered a problem where a third-party library that doesn't
work properly when included from source code that is compiled with -
fpack-struct. On Windows, there is an easy solution for this:
#include <pshpack8.h>
include third-party code here
#include <poppack.h>

I thought that I could do something similar with GCC using '#pragma
pack':
#pragma pack(push, 8)
include third-party code here
#pragma pack(pop)

The problem is that on Windows, the setting in <pshpack8.h>
*overrides* the project-level setting. However, with GCC, '#pragma
pack' is *ignored* if -fpack-struct is used.

At the moment, the only solution I can think of is to stop using -
fpack-struct and manually specify desired packing on every single
struct. However, this seems unnecessarily tedious and dangerously
error-prone.

Any advice here? There must be an easier way!

Thanks,
Adam

0 new messages