HPlogo HP C/HP-UX Reference Manual: Version A.05.55.02 > Chapter 7 Preprocessing Directives

_Pragma

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

_Pragma is a preprocessing unary operator.

Syntax

_Pragma (string-literal)

_Pragma is a new preprocessing operator and is a part of C99 standards. The string literal is destringized by deleting the L prefix, if present. _Pragma deletes the leading and trailing double quotes, replacing each escape sequence by a double-quote, and replacing the escape sequence by a single backlash. The resulting sequence of characters is processed to produce preprocessor tokens that are executed as if they were preprocessed tokens in a pragma directive.

The _Pragma operator provides portability in the use of an existing #pragma C preprocessor construct. These pragmas are processed as defined in its implementation. Most C implementations provide pragmas that are very similar in meaning and functionality. The _Pragma operator can be used in the replacement text of a macro, so as to aid in abstracting these specific pragmas a level higher.

Examples

The following examples list the usage of the _Pragma operator:

Example 7-1 _Pragma Operator Usage

A directive of the form,

#pragma listing on "..\listing.dir"

can also be expressed as,

_Pragma (listing on \"..\\listing.dir\"")

The latter form is processed as earlier, if it appears literally as shown or it results from macro replacement, as in:

# define LISTING(x) PRAGMA(listing on #x)
# define PRAGMA(x) _Pragma(#x)
LISTING (..\listing.dir)

Example 7-2 _Pragma Operator Usage

_Pragma("ALIGN 4")

expands to

#pragma ALIGN 4

Example 7-3 _Pragma Operator Usage

#define FOO "ALIGN 4"
_Pragma(FOO)

expands to

#pragma ALIGN 4

© Hewlett-Packard Development Company, L.P.