MS Style #pragma pack(push,...)

Zack Weinberg
Wed Jun 28 10:11:00 GMT 2000

On Wed, Jun 28, 2000 at 11:54:16AM -0500, Jeremy White wrote:
> I'm compiling Microsoft C++ code (MFC, in fact)
> for use with the Wine project under LINUX.
> As has been discussed previously, the MFC code has a lot of
> non standard extensions to the language.  The one I'm
> fighting right now is their use of #pragma pack(push/pop,...).
> gcc now handles this almost perfectly (see question #2, below),
> but you have to #define HANDLE_PRAGMA_PACK_PUSH_POP in
> order to enable this code.

This will be enabled by default for all Linux configurations in gcc
2.96, and may have been there in 2.95 as well.

> Second, the pattern of #pragmas that MS uses is similar
> to the following:
>     #define _PACKNUM 4
>     #pragma pack(push, _PACKNUM)
> Currently, gcc treats that as a compiler error, because it doesn't
> expand the macro in cccp.c.  I have revised cccp.c to solve
> this error, as is attached.

The new (1999) C standard requires some pragmas _not_ to be macro
expanded.  For consistency we'd like all pragmas not to be expanded,
unless some overriding concern exists.  This is a valid overriding
concern - but what that means is you need to make your patch specific
to #pragma pack.

Also, cccp.c no longer exists, and in general we cannot use patches
against anything but the current development sources.


More information about the Gcc mailing list