The _Pragma operator _Pragma introduced in C99 . _Pragma(arg) is an operator very similar to sizeof or defined , and can be embedded in macros.
At cpp.gnu.org :
Its syntax is _Pragma ( string-literal ) , where a literal string can be a regular or wide character string. It is destroyed, replacing everything \\ one \ and everything \" by " . Then the result is processed as if it were displayed on the right side of the #pragma . For instance,
_Pragma ("GCC dependency \"parse.y\"")
has the same effect as #pragma GCC dependency "parse.y" . The same effect can be achieved with macros, for example
#define DO_PRAGMA(x) _Pragma (#x) DO_PRAGMA (GCC dependency "parse.y")
According to IBM tutorial :
The _Pragma operator is an alternative method of specifying #pragma directives. For example, the following two statements are equivalent:
#pragma comment(copyright, "IBM 2010") _Pragma("comment(copyright, \"IBM 2010\")")
The IBM 2010 string is inserted into the C ++ object file when compiling the following code:
_Pragma("comment(copyright, \"IBM 2010\")") int main() { return 0; }
For more information about _pragma with an example.
source share