简体   繁体   English

C++/CLI 项目中的“将所有警告视为错误,除了...”

[英]“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.

相关问题 将特定级别的所有警告视为错误,但不将下一级别的警告视为错误 - Treat all warnings of specific level as errors but not those of next level 在C ++ / CLR项目中引用NuGet软件包时,编译器警告C4691 - Compiler warnings C4691 when referencing NuGet package in C++/CLR project 根据项目配置在C ++ / CLI包装器中引用x86和x64 DLL? - Referencing x86 and x64 DLL in C++/CLI wrapper based on project configuration? 多个错误,在VS2017的头文件中,opengl项目C ++ - Multiple errors, in header files in VS2017, opengl project C++ 将我的 c++ 项目升级到 VS19 后看到许多编译错误 - Seeing many compilation errors after upgrading my c++ project to VS19 C++/CLI 中的模板函数签名解包 - Template function signature unpacking in C++/CLI c ++ / cli检查网络连接 - c++/cli Checking Network Connectivity 如何在Package Manager控制台中选择除两个或三个项目以外的所有项目 - How to select all project except two or three project in Package Manager Console Visual Studio 2017 和 2019 C++/CLI 缺失 - Visual Studio 2017 and 2019 C++/CLI Missing 附加到 C++/CLI dll 的性能分析器无法访问本机 C++ 代码 - Perfomance profiler attached to C++/CLI dll doesn't reach native C++ code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM