如何在 VS 项目中禁用 clang-cl 特定警告 [英] How to disable clang-cl specific warnings in VS project
问题描述
我使用了一个 3rd 方项目,该项目会产生大量警告.我在 VS 项目属性中禁用了所有这些.有时,我切换到 LLVM clang-cl
工具集来检查来自 clang 的警告.第 3 方项目使用 clang-cl 产生如此多的警告,以至于 VS 被输出量阻塞.我知道如何禁用它们,我是通过命令行参数来实现的,例如:Wno-int-conversion -Wno-shift-op-parentheses
等.但是,当我切换回VS 工具集,所有这些用于禁用来自 clang-cl 的警告的命令行参数都变成了 MS 编译器的错误(未知的 cmd 行参数).
I use a 3rd party project, that produces huge amount of warnings. I disable all of them in VS project properties. Sometimes, I switch to LLVM clang-cl
toolset to check for warnings from clang. The 3rd party project produces so many warnings with clang-cl that VS is chocking with the amount of output.
I know how to disable them, I do so through command line args, for example: Wno-int-conversion -Wno-shift-op-parentheses
etc. The problem, however, when I switch back to VS toolset, all of these command line params to disable warnings from clang-cl become errors (unknown cmd line args) with MS compiler.
有没有办法在同一个 VS 项目中同时使用 clang 和 VS 设置?也许,以 ClangCL 工具集为条件,这些只能添加到 clang-cl 构建中?
Is there a way to have both clang and VS settings in the same VS project? Maybe, somehow conditional on ClangCL toolset these could be added only for clang-cl builds?
推荐答案
我尝试的第一件事马上就奏效了,以防万一有人需要解决同样的问题:
The first thing I tried worked right away, in case if anybody needs to solve the same problem:
<AdditionalOptions Condition="'$(PlatformToolset)'!='ClangCL'">/w24003 /w24005 ... %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(PlatformToolset)'=='ClangCL'">-Wno-unknown-pragmas -Wno-unused-variable ... %(AdditionalOptions)</AdditionalOptions>
通过这种方式,在 VS 中使用 LLVM clang-cl
工具集时,只应用了 clang cpecific 命令行参数,而在使用 ms 编译器时,只应用了 ms 编译器特定的选项.
This way, with using LLVM clang-cl
toolset with VS only clang cpecific command line params applies, and when using ms compiler, only ms compiler specific options are applied.
这篇关于如何在 VS 项目中禁用 clang-cl 特定警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!