ILE C/C++ Compiler Reference


_Packed Specifier

_Packed can be associated with struct, union, and in C++, class definitions. In C++, _Packed must be specified on a typedef. It has the same effect as #pragma pack(1). The following code shows examples of valid and invalid usages of _Packed. In these examples, the keywords struct, union, and class can be used interchangeably.

typedef _Packed class SomeClass { /* ... */ } MyClass;  // OK
typedef _Packed union AnotherClass {} PUnion;           // OK
typedef _Packed struct {} PAnonStruct;                  // Invalid, struct must be named
Class Stack { /* ... */ };
_Packed Stack someObject;                               // Invalid, specifier _Packed must be
                                                        // associated with a typedef in C++
_Packed struct SomeStruct { };                          // OK for C, invalid for C++
_Packed union SomeUnion { };                            // OK for C, invalid for C++

[ Top of Page | Previous Page | Next Page | Contents | Index ]