gpt4 book ai didi

windows - 在 Windows 上编译 Clang

转载 作者:可可西里 更新时间:2023-11-01 13:58:00 24 4
gpt4 key购买 nike

我按照 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com