Skip to main content

IAR Embedded Workbench for RISC-V 3.40

pack

In this section:
Syntax
#pragma pack(n)
#pragma pack()
#pragma pack({push|pop}[,name] [,n])
Parameters

n

Sets an optional structure alignment—one of 1, 2, 4, 8, or 16

Empty list

Restores the structure alignment to default

push

Sets a temporary structure alignment

pop

Restores the structure alignment from a temporarily pushed alignment

name

An optional pushed or popped alignment label

Description

Use this pragma directive to specify the maximum alignment of struct and union members.

The #pragma pack directive affects declarations of structures following the pragma directive to the next #pragma pack or the end of the compilation unit.

Note

This can result in significantly larger and slower code when accessing members of the structure.

Use either __packed or #pragma pack to relax the alignment restrictions for a type and the objects defined using that type. Mixing __packed and #pragma pack might lead to unexpected behavior.

See also

Structure types and __packed.