[英]Is there an option to turn on "warnings as errors" programmatically in C++ in Visual Studio?
I would like to turn on the "warnings as errors" feature for just me, but not other programmers who share the same code.我只想为我打开“警告作为错误”功能,而不是共享相同代码的其他程序员。 I can use a macro like
#ifdef MY_VERSION
to limit this.我可以使用像
#ifdef MY_VERSION
这样的宏来限制它。
However, I can't see a way to turn on this feature (the /WX
compiler switch) inside of the code.但是,我看不到在代码中打开此功能(
/WX
编译器开关)的方法。
Or alternatively, to set a range of warnings as errors, eg something like #pragma warning (error: 4000-4999)
which would let me set this for just me but noone else.或者,将一系列警告设置为错误,例如
#pragma warning (error: 4000-4999)
之类的东西,这样我就可以为自己设置这个,而不是为其他人设置。
Or possibly some other way to ensure that when code with MY_VERSION
defined is built, warnings are treated as errors, but when it isn't defined, they aren't.或者可能是其他一些方法来确保在构建定义了
MY_VERSION
的代码时,警告被视为错误,但当它未定义时,它们就不是。
I've tried to find something in the MS docs, but haven't managed to do so.我试图在 MS 文档中找到一些东西,但没有成功。 There may be something involving the "Project Engine", but if so I don't understand how to go about it.
可能有一些涉及“项目引擎”的东西,但如果是这样,我不明白如何 go 关于它。
You can achieve the same effect by simply setting it in your project.您只需在项目中设置即可达到相同的效果。 (properties)(c++)(general) set treat warnings as errors to Y. Your cohorts leave it at 'N'.
(properties)(c++)(general) set treat warnings as errors to Y. 你的同伙把它留在'N'。
Note that I am assuming that each developer has their own project setup.请注意,我假设每个开发人员都有自己的项目设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.