INF: #pragma pack() Affects Declarations, Not Definitions

ID Number: Q40027

5.x 6.00 6.00a 6.00ax | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, and 6.0ax, the pack

pragma affects declarations; not definitions. Place #pragma pack()

prior to data declarations.

More Information:

The following program demonstrates usage of #pragma pack():

/* Elements of variables of type struct x will be byte-aligned. */

#pragma pack(1)

struct x { int a; char b; int c; };

/* Elements of variables of type struct y will be word-aligned. */

#pragma pack(2)

struct y { int a; char b; int d; };

/* The pragma below does NOT affect the definitions that follow. */

#pragma pack(4)

struct x X;

struct y Y;

void main (void)

{ /* dummy main */ }

Additional reference words: 5.00 6.00 6.00a 6.00ax