HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
UNALIGN
#pragma unalign [1|2|4|8|16]
typedef T1 T2;
T1 and T2 have the same size and layout, but with specified alignment requirements.
HP aCC supports misaligned data access using the unalign pragma. The unalign
pragma can be applied on typedef to define a type with special alignment. The
unalign pragma takes effect only on next declaration.
If the unalign pragma declaration is not in the global scope or if it is not a typedef,
compiler displays a warning message. If the specified alignment is greater than the
original alignment of the declaration, then an error message is displayed, and the pragma
is ignored.
Example:
#pragma unalign 1
typedef int ua_int; // ua_int is of int type with 1 byte alignment
typedef ua_int *ua_intPtr; // this typedef is not affected by the above
// unalign pragma. It defines a pointer type
// which points to 1 byte aligned data
The interaction between pack and unalign pragmas is as follows:
#pragma pack 1
struct S {
char c;
int i;
};
#pragma pack 0
S s;
ua_int *ua_ip = &s.i; // ua_ip points to 1 byte
// aligned int
*ua_ip = 2; // mis-aligned access to
// 1 byte aligned int
NOTE: The HP_ALIGN pragma, which is supported by the HP ANSI C compiler, is not
supported by aCC. The pack and unalign pragmas can replace most of the HP_ALIGN
functionality.
Optimization Pragmas
Following are the optimization pragmas supported by the HP aC++ compiler:
OPT_LEVEL Pragma
#pragma OPT_LEVEL 0
#pragma OPT_LEVEL 1
#pragma OPT_LEVEL 2
#pragma OPT_LEVEL 3
124 Pragma Directives and Attributes