Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is __pragma and what are the differences between __pragma and #pragma

Tags:

c++

macros

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))
like image 635
jhy Avatar asked Dec 14 '22 22:12

jhy


1 Answers

#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).

like image 178
Cameron Avatar answered Dec 17 '22 13:12

Cameron