Names specified here
Name Description Notes Source Availability
#pragma Control compilation L Directive C89 C90 C95 C99 C11
_Pragma Control compilation L + Keyword C99 C11

The preprocessor #pragma directive modifies the translation process in an implementation-defined way, possibly not in conformance with the Standard. It has the following grammar:

control-line
# pragma pp-tokensopt new-line

For example:

struct hdr {
#pragma pack
  unsigned short flags;
  unsigned short type;
};

The scope of the pragma is also implementation-defined. It might only affect the rest of the current declaration, the current block, or the translation unit.

Before C99, there are no standard pragmas. Consult the documentation for your compiler to find out what pragmas it supports. Even though unrecognized pragmas are ignored, it is recommended to use pragmas with conditional compilation, in case the same pragma is recognized by two different implementations to mean different things.

From C99, if the first token is STDC, the tokens are not subject to macro expansion, and they must match one of the following forms:

#pragma STDC FP_CONTRACT on-off-switch
#pragma STDC FENV_ACCESS on-off-switch
#pragma STDC CX_LIMITED_RANGE on-off-switch
on-off-switch
ON
OFF
DEFAULT

From C99, there is also a _Pragma preprocessing operator, matching _Pragma ( string-literal ) . When the preprocessor encounters such a construct, it submits the contents of the string to translation phase 3, and the resulting tokens are treated as if they belong to a #pragma directive. For example:

_Pragma ("foo bar \"..\\baz\\qux\"")

…is interpreted as if it were:

#pragma foo bar "..\baz\qux"

CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2022-06-17T21:43:05.000+0000