在 VS2019 中使用 clang-cl 构建项目

Building project with clang-cl in VS2019

我正在尝试在 Visual Studio 2019 中使用 clang-cl 构建一个项目,检查项目属性中的 C++17 选项。我收到警告:

constexpr if is a C++17 extension [-Wc++17-extensions]

我想它应该只出现在未编译为 C++17 的代码中。那我为什么会得到这个?代码编译成C++17?

一种可能是您为项目选择了不同的标准,并在该项目中选择了单独的源文件。尝试检查 属性 sheet 中 'offending' 源文件的“语言”选项——确保它也设置为使用 C++17 标准。