Structure Packing Pragma
The pack pragma can be used within LabWindows/CVI to specify the maximum alignment factor for elements within a structure. For example, assume the following structure definition:
struct t {
double d1;
char charVal;
short shortVal;
double d2;
};
If the maximum alignment is 1, the compiler can start the structure on any 1-byte boundary and inserts no gaps between the structure elements.
If the maximum alignment is 8, the compiler must start the structure on an 8-byte boundary, place shortVal on a 2-byte boundary, and place d2 on an 8-byte boundary.
You can set the maximum alignment as follows:
#pragma pack(4) /* sets maximum alignment to 4 bytes */
#pragma pack(8) /* sets maximum alignment to 8 bytes */
#pragma pack() /* resets to the default*/
The maximum alignment the compiler applies to a structure is based on the last pack pragma statement it sees before the definition of the structure.