禁用单个警告错误 [英] Disable single warning error

查看:144
本文介绍了禁用单个警告错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以禁用Visual Studio的cpp文件中的单个警告行?



例如,如果我捕获异常并且不处理它,我得到错误4101(未引用的局部变量)。有没有办法忽略这个功能,但否则报告在编译单元?目前,我在文件的顶部放了 #pragma warning(disable:4101),但显然只是关闭整个单元。

解决方案

  #pragma warning(push)
#pragma warning(disable:4101)
//您的函数
#pragma warning(pop)


Is there a way to disable just a single warning line in a cpp file with visual studio?

For example, if I catch an exception and don't handle it, I get error 4101 (unreferenced local variable). Is there a way to ignore this just in that function, but otherwise report it in the compilation unit? At the moment, I put #pragma warning (disable : 4101) at the top of the file, but that obviously just turns it off for the whole unit.

解决方案

#pragma warning( push )
#pragma warning( disable : 4101)
// Your function
#pragma warning( pop ) 

这篇关于禁用单个警告错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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