windows - 在 Windows 上编译 Clang

标签 windows llvm clang

我按照 http://clang.llvm.org/get_started.html 中的说明进行操作

我用 MSVC 2010 编译了 llvm 和 clang 的最新主干。现在我可以用 Clang 编译简单的程序,但是当我尝试编译这个程序时,我遇到了很多错误。 这是程序:

#include <algorithm>
int main(){ return 0; }

下面是一些错误:

In file included from hello.cpp:1:
In file included from C:\Program Files\Microsoft Visual Studio 10.0\VC\include\algorithm:6:
In file included from C:\Program Files\Microsoft Visual Studio 10.0\VC\include\memory:987:
In file included from C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h:24:
In file included from H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\immintrin.h:32:
In file included from H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\xmmintrin.h:988:
H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\emmintrin.h:1384:22: error: expected expression
  return (__m128)__in;
                     ^
H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\emmintrin.h:1390:23: error: expected expression
  return (__m128i)__in;
                      ^
H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\emmintrin.h:1396:23: error: expected expression
  return (__m128d)__in;
                      ^

Clang 的完整输出:http://pastebin.com/qi87K8qr

Clang 尝试使用 MSVC header ,但它不起作用。也许我应该改用 libc++ 或 libstdc++,但该怎么做?

注意我对预编译的 clang 二进制文件不感兴趣

最佳答案

是的,clang 根本不支持 Microsoft 的所有扩展 C++ 语法,因此无法解析使用该语法的 Microsoft C++ header 。不仅如此,Clang 也不完全支持 Microsoft 的 C++ ABI、名称修改等。不过,我相信 Windows 上的 Clang 可以与 C 一起正常工作。

要使用不同的 C++ 标准库,您可以使用 IIRC、-nostdinc++-nostdlib++ 让 clang 忽略正常的头文件和库目录。然后你可以告诉 clang 你想要使用的包含和库目录(使用 -isystem-I 或其他)。但是我不确定 libc++ 或 libstdc++ 是否在这些情况下工作,因为它们可能依赖于 Windows C 运行时库没有的东西。

关于windows - 在 Windows 上编译 Clang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14902683/

相关文章:

windows - WINSDK : Determining whether an arbitrary pid identifies a running process on Windows

windows - 如何在配备 Tesla 的基于 Windows 的主机上使用 OpenGL 进行渲染

llvm - 如何在 LLVM 中列出目标特定属性?

c - 在 llvm 链接 *.a 和 *.o 文件时出错

c - LLVM 解释器 (lli) 和共享对象加载

javascript - 如何运行现有的 react native 项目

c++ - HeapAlloc 间歇性失败

c++ - 错误 : no match for ‘operator*’ (operand type is ‘const llvm::DataLayout’ )

python - 如何解决clang的Python绑定(bind)加载错误?

python - 升级到Macos Big Sur后Reportlab安装失败