什么是 __pragma 以及 __pragma 和 #pragma 之间有什么区别 [英] What is __pragma and what are the differences between __pragma and #pragma

查看:28
本文介绍了什么是 __pragma 以及 __pragma 和 #pragma 之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下宏让我感到困惑.我想知道 __pragma 是什么,__pragma 和 #pragma 有什么区别.

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

推荐答案

#pragma 本身就是一个预处理器指令;它不能在 #define 指令中使用.

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

所以,这就是 __pragma 存在的原因:它提供了一种从使用它的宏展开的任何地方发出 pragma 的方法.

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.

这是一个非标准的编译器扩展(MSVC、Intel 和一些 C 编译器在不同程度上支持它).另请参阅在较新版本的 C/C++ 标准(以及用途相同,但语法略有不同).

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

这篇关于什么是 __pragma 以及 __pragma 和 #pragma 之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆