HP C A.06.05 Reference Manual
Compiling and Running HP C Programs
Pragmas
Chapter 9228
For example, the following command builds the name $CODE&MINE$:
#pragma locality “mine”
Code that is not headed by a LOCALITY pragma is associated with the name $CODE$. An empty
"
string
" causes the code name to revert to the default name of $CODE$.
VERSIONID Pragma
#pragma VERSIONID "
string
"
Specifies a version string to be associated with a particular piece of code. The
string
is placed
into the object file produced when the code is compiled.
Data Alignment Pragmas
This section discusses the data alignment pragmas HP_ALIGN and PACK and their various
arguments available on the HP-UX systems, to control alignment across platforms. In the
following discussion, a word represents a 32-bit data structure. Refer to HP aC++/HP C
Programmer's Guide for detailed information on the HP_ALIGN and PACK pragmas.
ALIGN Pragma
#pragma align N
N is a number raised to the power of 2.
HP aC++ supports user specified alignment for global data. The pragma takes effect on next
declaration. If the align pragma declaration is not in the global scope or if it is not a data
declaration, the compiler displays a warning message. If the specified alignment is lesser than
the original alignment of data, a warning message is displayed, and the pragma is ignored.
#pragma align 2
char c; // "c" is at least aligned on 2 byte boundary
#pragma align 64
int i, a[10]; // "i" and array "a" are at least aligned 64 byte boundary.
// the size of "a" is still 10*sizeof(int)
PACK Pragma
#pragma PACK
n
The PACK pragma is a simple, intuitive way for users to specify alignment. In the syntax,
n
is
the byte boundary on which members of structs and unions should be aligned, and can be 1, 2,
4, 8, or 16.