为什么clang ++会编译它:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
printf("Hello World!\n");
return EXIT_SUCCESS;
}
并且不想编译它:
#include <iostream>
int main()
{
std::cout << "FFFF\n";
return 0;
}
???
命令行:
clang ++ -c hello.cpp -emit-llvm -o hello.bc
发出的错误太多了:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xrefwrap:222:22:
note:
expanded from macro '_CLASS_RESULT_OF_PMF_OPT_0X'
__thiscall, X2, X3, X4)
Windows 7 64,clang-3.2,llvm-3.2,VS2012
===== UPDATE =====
命令行(使用-v):
clang++ -c hello.cpp -emit-llvm -o hello.bc -v
我得到了什么:
clang version 3.2 (tags/RELEASE_32/final) Target: i686-pc-win32 Thread model: posix "C:/llvm/clang/build/bin/Debug/clang++.exe" -cc1 -triple i686-pc-win32 -emit-ll vm-bc -disable-free -main-file-name 321.cpp -mrelocation-model static -mdisable- fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -m omit-leaf-frame-pointer -v -coverage-file "C:\llvm\3211.bc" -resource-dir "C:/ llvm/clang/build/bin/Debug\..\lib\clang\3.2" -fmodule-cache-path "C:\Users\ \kpdev\AppData\Local\Temp\clang-module-cache" -internal-isystem C:/llvm/clan g/build/bin/Debug/../lib/clang/3.2/include -internal-isystem "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include" -internal-isystem "C:\Program Files (x86)\Windows Kits\8.0\\include" -std=c++11 -fdeprecated-macro -ferro r-limit 3 -fmessage-length 80 -mstackrealign -fms-extensions -fms-compatibility -fmsc-version=1300 -fdelayed-template-parsing -fobjc-runtime=gcc -fobjc-default- synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -f color-diagnostics -o "C:\llvm\3211.bc" -x c++ "C:\llvm\321.cpp" clang -cc1 version 3.2 based upon LLVM 3.2svn default target i686-pc-win32 #include "..." search starts here: #include <...>search starts here: C:/llvm/clang/build/bin/Debug/../lib/clang/3.2/include C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include C:\Program Files (x86)\Windows Kits\8.0\include End of search list. In file included from C:\llvm\321.cpp:1: In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\inc lude\iostream:6: In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\inc lude\istream:6:...等
然后:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\type_traits:1072: 33: error: '_Ty' does not refer to a value _HAS_TRIVIAL_MOVE_CONSTRUCTOR(_Ty) ^ C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\type_traits:52:38 : note: expanded from macro '_HAS_TRIVIAL_MOVE_CONSTRUCTOR' && __has_trivial_move_constructor(_Ty)> ^...等
所以... -internal-isystem
指向错误的路径。如何改变?
答案 0 :(得分:1)
您为clang配置了错误的包含路径。这样:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xrefwrap
是来自VS 2012安装的头文件,并且与clang有关(并且显然与它不兼容)。
确保没有为VC ++编译设置环境。例如,确保没有为VC ++设置的INCLUDE
环境变量。可能还有其他env变量,以确保不会为clang设置不当,例如LIB
。