Windows   发布时间:2022-05-07  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在Windows上使用clang编译c 11程序时出错大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经在 Windows上构建了clang 3.2并且正在尝试构建一个简单的Hello world程序.但是我收到了很多错误,如下所示.
d:\Marius\xyz>clang++ -stdlib=libc++ -std=c++11 -Wall xyz.cpp -o xyz.exe
clang++: warning: argument unused during compilation: '-stdlib=libc++'
In file included from xyz.cpp:12:
In file included from ./stdafx.h:18:
In file included from C:\Program Files (x86)\Microsoft Visual studio 11.0\VC\include\algorithm:6:
In file included from C:\Program Files (x86)\Microsoft Visual studio 11.0\VC\include\xmemory:6:
In file included from C:\Program Files (x86)\Microsoft Visual studio 11.0\VC\include\xmemory0:9:
In file included from C:\Program Files (x86)\Microsoft Visual studio 11.0\VC\include\xutility:8:
In file included from C:\Program Files (x86)\Microsoft Visual studio 11.0\VC\include\utility:8:
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\xstddef:540:50: note:
      expanded from macro '_VARIADic_EXPAND_4'
#define _VARIADic_EXPAND_4(FUNC,X1,X2,X3,X4) \
                                                 ^
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,X4)
                                          ^
Fatal error: too many errors emitted,stopping Now [-ferror-limit=]
20 errors generated.

我收到很多这样的错误,来自VC 2012标题.是否有可能在Windows上使用clang构建C 11代码?我是否必须提供额外的命令切换?

当由Visual studio构建时,Clang无法正常工作(据说它可以在由MinGW构建时工作,但我无法自己验证).

构建Clang时,它被配置为使用用于构建它的库.由于您使用Visual studio构建了Clang,因此Clang将尝试使用Visual studio头文件和库.不幸的是,Clang和Visual studio的内部结构不同,Clang无法使用特定于VS的标头.

直到libc++可以为Windows编译,Clang将(几乎可以肯定)在Visual studio编译时不会工作.尝试使用MinGW构建它(并制作博客文章或者你如何做到这一点!),看看它是否适合你.

大佬总结

以上是大佬教程为你收集整理的在Windows上使用clang编译c 11程序时出错全部内容,希望文章能够帮你解决在Windows上使用clang编译c 11程序时出错所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: