[英]“Treat all warnings as errors except…” in C++/CLI project
In C# projects ( .csproj
files), it is possible to treat all warnings as errors except a specific set of warnings .在 C# 项目(
.csproj
文件)中, 可以将所有警告视为错误,除了一组特定的警告。 Typically, this makes sense for obsolete / deprecated warnings, as these are there specifically to not break a build while announcing an upcoming API change.通常,这对于过时/不推荐使用的警告是有意义的,因为这些警告专门用于在宣布即将发生的 API 更改时不会破坏构建。
Is the same also possible somehow for C++/CLI projects, ie in .vcxproj
files?对于 C++/CLI 项目(即在
.vcxproj
文件中)是否也有可能?
(I am referring to seeing C4947 as a warning despite all other warnings being treated as errors.) (我是指将C4947视为警告,尽管所有其他警告都被视为错误。)
An answer from 2017 suggests it is not possible for plain C++ projects compiled by Microsoft's compiler by means of a compiler switch. 2017 年的回答表明,微软编译器通过编译器开关编译的普通 C++ 项目是不可能的。 However, I am hoping for the
.vcxproj
Xml format to support some element that causes such a behaviour.但是,我希望
.vcxproj
Xml 格式支持导致这种行为的某些元素。
I have tried inserting the <WarningsNotAsErrors>4947</WarningsNotAsErrors>
element from the .csproj
file into the .vcxproj
file, but that won't help.我尝试将
<WarningsNotAsErrors>4947</WarningsNotAsErrors>
元素从.csproj
文件插入到.vcxproj
文件中,但这无济于事。 Also, seeing that <TreatWarningsAsErrors>
from the .csproj
file is called <TreatWarningAsError>
in .vcxproj
(ie singular instead of plural), I tried <WarningNotAsError>4947</WarningNotAsError>
, but to no avail.此外,看到
.csproj
文件中的<TreatWarningsAsErrors>
<TreatWarningAsError>
在.vcxproj
中称为 <TreatWarningAsError> (即单数而不是复数),我尝试了<WarningNotAsError>4947</WarningNotAsError>
,但无济于事。
I have read somehints about treating only specific warnings as errors, but this, of course, is not a viable solution.我已经阅读了一些关于仅将特定警告视为错误的提示,但这当然不是一个可行的解决方案。 There are hundreds, if not thousands, of warnings (possibly even more in future compiler versions), all of which I want to treat as errors, except for a single one.
有成百上千个警告(在未来的编译器版本中可能会更多),我想将所有这些都视为错误,除了一个。
Have been wanting to do this as well, though more generally for C++.也一直想这样做,但更普遍的是 C++。
Mainly for deprecating functions just like this post here, which has a couple of suggested workarounds.主要用于弃用功能,就像这里的这篇文章一样,其中有一些建议的解决方法。
https://social.msdn.microsoft.com/forums/vstudio/en-US/88ffa3e4-1ad4-410a-b50b-d6575cb914bd/override-wx-behavior-using-pragma-warning https://social.msdn.microsoft.com/forums/vstudio/en-US/88ffa3e4-1ad4-410a-b50b-d6575cb914bd/override-wx-behavior-using-pragma-warning
Not sure whether it suits your situation.不确定它是否适合您的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.