How to disable clang-cl specific warnings in VS project

非 Y 不嫁゛ 提交于 2020-07-09 16:10:01

问题


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.

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?


回答1:


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>

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.



来源:https://stackoverflow.com/questions/61457022/how-to-disable-clang-cl-specific-warnings-in-vs-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!