g++如果我使用 #pragma GCC 诊断,则会抱怨 #pragma 区域
我需要在包含文件中禁用警告。
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
<some function>
#pragma GCC diagnostic pop
但是,在包括上述.h文件的main.cpp文件中,
#pragma region class_definitions
我知道它是“不是标准的pragma” - 我使用它来控制主文件中的大量声明,因为我将VS用于编辑代码,在我去Linux 之前
,我会得到此警告(如果我不使用#pragma gcc诊断push/pop
,那就不会出现,
warning: ignoring ‘#pragma region class_definitions’ [-Wunknown-pragmas]
是否有办法吃蛋糕并吃掉它?
编辑: 我尝试过,警告仍然显示
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma region class_definitions
#pragma GCC diagnostic pop
I need to disable warning in an include file.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
<some function>
#pragma GCC diagnostic pop
however in the main.cpp file which includes the above .h file I use
#pragma region class_definitions
I know it is "not standard pragma" - I use it to control huge amount of declarations in the main file as I use VS for editing code, before I go to linux
So I get this warning (which does NOT appear if I dont use #pragma GCC diagnostic push/pop
)
warning: ignoring ‘#pragma region class_definitions’ [-Wunknown-pragmas]
Is there a way to have a cake AND eat it?
EDIT: I tried this and the warning still shows
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma region class_definitions
#pragma GCC diagnostic pop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我伪造了 #pragma 区域,如下所示。
VSCode 折叠/展开的方式与#pragma 区域相同; GCC 编译器对此很满意。
并不完美……但是 VSCode 折叠功能太重要了,不能失去。
I have faked #pragma region as follows.
VSCode does collapse/expand in the same way as #pragma region; and the GCC compiler is fine with it.
Not perfect... but the VSCode collapse feature is too important to lose.