The LOCALITY_ALL pragma specifies a name to be associated with the linker procedures and global variables that should be grouped together at program binding or load time.

These are written to a relocatable object module. All procedures and global variables following the LOCALITY_ALL pragma are associated with the name specified in the string.

VERSIONID

#pragma VERSIONID "string"

string is a string of characters that HP aC++ places in the object file.

The VERSIONID pragma 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.

For example, the directive

#pragma VERSIONID "Software Product, Version 12345.A.01.05"

places the characters Software Product, Version 12345.A.01.05 into the object file.

Data Alignment Pragmas

This section discusses the data alignment pragmas and their various arguments available on HP-UX systems to control alignment across platforms.

ALIGN

#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 less than the original alignment of data, a warning message is displayed, and the pragma is ignored. Note that for C code you must initialize the variables, otherwise the compiler will generate a warning.

#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 PACK [n][pushpop][,<name>][,n]show]

n can be 1, 2, 4, 8, or 16 bytes. If n is not specified, maximum alignment is set to the default value.

This file-scoped pragma allows you to specify the maximum alignment of class fields. The alignment of the whole class is then computed as usual, to the alignment of the most aligned field in the class.

NOTE: The result of applying #pragma pack n to constructs other than class definitions (including struct definitions) is undefined and not supported. For example:

#pragma pack 1

int global_var; // Undefined behavior: not a class definition

void foo() { // Also undefined

}

Example:

struct S1 {

 

char c1;

// Offset 0, 3 bytes padding

98 Pragma Directives and Attributes

Page 98
Image 98
HP C/aC++ for PA-RISC Software manual Data Alignment Pragmas, #pragma Versionid string, #pragma align N