MSVC - 在标题中停止警告 [英] MSVC - stop warnings in headers

查看:121
本文介绍了MSVC - 在标题中停止警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MSVC与CMaked项目。结果,我启用了MSVC上启用了gcc和clang的许多标志。然而,/墙警告水平给我一些痛苦;它警告我所包括的头文件中的各种事情,如stdio.h和boost标头。有没有办法阻止MSVC警告我的标题中的事情?

解决方案

/ Wall 非常拙劣的。 / W4 可能是你真正需要的。要回答您的问题,您可以通过以下方式停用标头周围的特定警告:

  #pragma warning(disable:xxxx)
#include< yourheader.h>
#pragma warning(default:xxxx)

p>

  #pragma warning(push,3)
#include< yourheader.h>
#pragma warning(pop)

请参阅MSDN文档: http://msdn.microsoft.com/en-us/library/2c8f766e.aspx p>

I'm using MSVC with a CMaked project. As a result, I've enabled many of the flags on MSVC which were enabled for gcc and clang. However, the /Wall warning level is giving me some pain; it warns me about all kinds of things in included headers, like stdio.h and boost headers. Is there a way to stop MSVC from warning me about things in headers? I like my warning levels, but I only want them enabled for me.

解决方案

/Wall is very pedantic. /W4 is probably all you really need. To answer your question, you can disable specific warnings around your headers with:

 #pragma warning(disable:xxxx)
 #include <yourheader.h>
 #pragma warning(default:xxxx)

Or change the warning level with:

 #pragma warning(push,3)
 #include <yourheader.h>
 #pragma warning(pop)

See the MSDN documentation: http://msdn.microsoft.com/en-us/library/2c8f766e.aspx

这篇关于MSVC - 在标题中停止警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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