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. For those options that have equivalent pragma directives, you can have several ways to specify the syntax of the pragmas:
  • Using #pragma options option_name syntax — You can use command-line options with the #pragma options syntax, which takes the same name as the option, and suboptions with a syntax identical to that of the option. For example, if the command-line option is:
    -qhalt=w
    The pragma form is:
    #pragma options halt=w
    The descriptions for each individual option indicates whether this form of the pragma is supported. For details, see #pragma options.
  • Using #pragma name syntax — Some options also have corresponding pragma directives that use a pragma-specific syntax, which may include additional or slightly different suboptions. Throughout the section Individual option descriptions, each option description indicates whether this form of the pragma is supported, and the syntax is provided.
  • Using the standard C99 _Pragma operator — For options that support either forms of the pragma directives listed above, you can also use the C99 _Pragma operator syntax in both C and C++.
Complete details on pragma syntax are provided in Pragma directive syntax.

Other pragmas do not have equivalent command-line options; these are described in detail throughout Compiler pragmas reference.

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 suboptions are listed in the detailed descriptions of the pragmas to which they apply.