6

The following macros confused me. I wondering what is __pragma and wwhat are the differences between __pragma and #pragma.

#define OPENVDB_START_THREADSAFE_STATIC_WRITE       __pragma(warning(disable:1711))
#define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE      __pragma(warning(default:1711))
Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
jhy
  • 193
  • 1
  • 2
  • 9
  • 2
    `The __pragma keyword, which is specific to the Microsoft compiler, enables you to code pragma directives within macro definitions.` (http://msdn.microsoft.com/en-us/library/d9x1s805.aspx) – Anirudh Ramanathan May 21 '14 at 17:31

1 Answers1

15

#pragma is a preprocessor directive in its own right; it can't be used within a #define directive.

So, this is why __pragma exists: it provides a way for a pragma to be issued from wherever the macro that uses it is expanded.

This is a non-standard compiler extension (MSVC, Intel, and some C compilers support it to varying degrees). See also the _Pragma operator that is defined in newer versions of the C/C++ standards (and serves the same purpose, but with a slightly different syntax).

Community
  • 1
  • 1
Cameron
  • 96,106
  • 25
  • 196
  • 225
  • 1
    Standard C, as of the 1999 standard (which Microsoft doesn't support) has a `_Pragma` operator, which is probably similar to Microsoft's `__pragma`. – Keith Thompson May 21 '14 at 17:38