Implementation defined behavior control
Implementation defined behavior is controlled by #pragma
directive.
Contents |
[edit] Syntax
#pragma pragma_params
|
(1) | ||||||||
_Pragma ( string-literal )
|
(2) | (since C++11) | |||||||
L
prefix (if any), the outer quotes, and leading/trailing whitespace from string-literal, replaces each \"
with "
and each \\
with \
, then tokenizes the result (as in translation stage 3), and then uses the result as if the input to #pragma
in (1)
[edit] Explanation
Pragma directive controls implementation-specific behavior of the compiler, such as disabling compiler warnings or changing alignment requirements. Any pragma that is not recognized is ignored.
[edit] Non-standard pragmas
The ISO C++ language standard does not require the compilers to support any pragmas. However, several non-standard pragmas are supported by multiple implementations:
[edit] #pragma STDC
ISO C language standard requires that C compilers support the following three pragmas, and some C++ compiler vendors support them, to varying degrees, in their C++ frontends:
#pragma STDC FENV_ACCESS arg
|
(1) | ||||||||
#pragma STDC FP_CONTRACT arg
|
(2) | ||||||||
#pragma STDC CX_LIMITED_RANGE arg
|
(3) | ||||||||
where arg is either ON
or OFF
or DEFAULT
.
ON
, informs the compiler that the program will access or modify floating-point environment, which means that optimizations that could subvert flag tests and mode changes (e.g., global common subexpression elimination, code motion, and constant folding) are prohibited. The default value is implementation-defined, usually OFF
.ON
.+v2
), and |x+iy| = √x2
+y2
, despite the possibility of intermediate overflow. In other words, the programmer guarantees that the range of the values that will be passed to those function is limited. The default value is
OFF
The behavior of the program is undefined if any of the three pragmas above appear in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement.
[edit] #pragma once
This section is incomplete |
[edit] #pragma pack
This section is incomplete |
[edit] See also
C documentation for Implementation defined behavior control
|
[edit] External links
- C++ pragmas in Visual Studio 2015
- Pragmas accepted by GCC 4.9.2
- Individual pragma descriptions and Standard pragmas in IBM AIX XL C 13.1
- Appendix B. Pragmas in Sun Studio 11 C++ User's Guide
- Intel C++ compiler pragmas
- HP aCC compiler pragmas