我正在使用VS2019,发现它可以与clang一起使用。所以我安装了clang,在使用VS2019时遇到了一些问题。但是,此问题仅基于编译器。似乎如果我要使用命令行进行编译:
C:\Program Files\LLVM\msbuild-bin\cl.exe /std:c++17 source.cpp
source.cpp包含:
#include <tuple>
#include <iostream>
void fn(int x)
{
std::cout << x << std::endl;
}
int main()
{
std::tuple<int> x(1);
apply(fn, x);
return 0;
}
倒闭:
clang-cl.exe: warning: argument unused during compilation: '/std:c++17' [-Wunused-command-line-argument]
In file included from source.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\tuple:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\new:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\exception:7:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\yvals.h:7:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\yvals_core.h(334,2): error: STL1000: Unexpected compiler version, expected Clang 7 or newer.
#error STL1000: Unexpected compiler version, expected Clang 7 or newer.
^
source.cpp(12,3): error: use of undeclared identifier 'apply'
apply(fn, x);
^
2 errors generated.
但是,如果我使用:
"C:\Program Files\LLVM\bin\clang-cl" /std:c++17 source.cpp
一切都很好。
事实是,VS2019使用的是以前的编译器可执行文件。如何使用后者?
我要更改构建器的唯一一件事就是去更改此项目:
还有什么我要改变的吗?