Specifying compiler options in program source files

You can specify compiler options within your program source by using pragma directives.

A pragma is an implementation-defined instruction to the compiler. It has one of the general forms given below:

Read syntax diagramSkip visual syntax diagram              .--------------------.
              V                    |
>>-#--pragma----character_sequence-+---------------------------><

Where character_sequence is a series of characters that give specific compiler instruction and arguments, if any.

The unary operator _Pragma allows a preprocessor macro to be contained in a pragma directive.

Read syntax diagramSkip visual syntax diagram>>-_Pragma--(string_literal)-----------------------------------><

The string_literal may be prefixed with L, making it a wide-string literal. The string literal is destringized and tokenized. The resulting sequence of tokens is processed as if it appeared in a pragma directive. For example:

_Pragma ( "pack(full)" ) 

would be equivalent to

#pragma pack(full)

The character_sequence on a pragma is subject to macro substitutions, unless otherwise stated. More than one pragma construct can be specified on a single #pragma directive. The compiler ignores unrecognized pragmas, issuing an informational message indicating this.

Options specified with pragma directives in program source files override all other option settings, except other pragma directives. The effect of specifying the same pragma directive more than once varies. See the description for each pragma for specific information.

Pragma settings can carry over into included files. To avoid potential unwanted side-effects from pragma settings, you should consider resetting pragma settings at the point in your program source where the pragma-defined behavior is no longer required. Some pragma options offer reset or pop suboptions to help you do this.

These #pragma directives are listed in the detailed descriptions of the options to which they apply. For complete details on the various #pragma preprocessor directives, see Individual pragma descriptions.

Related information