如何让clang 编译 c3.2支援c++11

Visual Studio, GCC, Clang, Intel 对 C++11 特性的支持一览表 - 开源中国社区
Visual Studio, GCC, Clang, Intel 对 C++11 特性的支持一览表
英文原文:
It’s been more than half a year since my
of the C++11 support across different compilers. This time I’d like to see how different compilers stack up based on the documentation for the pre-release versions of these compilers.
The next release of GCC is 4.8 and the upcoming version of Clang is 3.3. If you use Visual Studio 2012, you can install an experimental CTP update released in November 2012 to get additional C++11 features.
距离我已经有大半年了。这次我来根据这些预览版的编译器的文档来看下它们是如何堆砌起来的。
GCC的下个版本是4.8,以及Clang即将到来的版本是3.3 。如果你使用Visual Studio 2012,你可以安装2012年11月更新支持C++11额外特征的体验版CTP。
I’ve also thrown in v.13.0 of Intel’s C++ compiler out of curiosity, although it isn’t pre-release and there were a few features I couldn’t find information about. I didn’t find any information about the upcoming version of this compiler.
VS2012 Nov CTP
Intel 13.0
Rvalue references and move semantics
Lambda expressions
static_assert
Range based for loop
Trailing return type in functions
extern templates
&& for nested templates
Local and unnamed types as template arguments
Variadic macros
Variadic templates
Default template arguments in function templates
final method keyword
override method keyword
Strongly typed enums
Forward declared enums
Initializer lists
explicit type conversion operators
Raw string literals
Forwarding constructors
Template aliases
Defaulted methods
Deleted methods
New built-in types
Alignment support
Inline namespaces
sizeof on non-static data members without an instance
Changed restrictions on union members
User defined literals
Encoding support in literals
Arbitrary expressions in template deduction contexts
Don’t know
Non-static data member initializers
Don’t know
C99 compatibility
Generalized attributes
Thread local storage
Inheriting constructors
Rvalue references for *this
Minimal support for garbage collection
Don’t know
It looks like GCC is overtaking Clang as the compiler with the best C++11 support. Visual Studio has added several significant C++11 features such as variadic templates, initializer lists and raw literals.
我也对V.13.0的Intel C++编译器感到好奇,虽然它还不是预览版并且我也找不到有关它的新特性的信息。我没找到任何有关这个即将发行版本的编译器的信息。
VS2012 Nov CTP
Intel 13.0
Rvalue references and move semantics
Lambda expressions
static_assert
Range based for loop
Trailing return type in functions
extern templates
&& for nested templates
Local and unnamed types as template arguments
Variadic macros
Variadic templates
Default template arguments in function templates
final method keyword
override method keyword
Strongly typed enums
Forward declared enums
Initializer lists
explicit type conversion operators
Raw string literals
Forwarding constructors
Template aliases
Defaulted methods
Deleted methods
New built-in types
Alignment support
Inline namespaces
sizeof on non-static data members without an instance
Changed restrictions on union members
User defined literals
Encoding support in literals
Arbitrary expressions in template deduction contexts
Don’t know
Non-static data member initializers
Don’t know
C99 compatibility
Generalized attributes
Thread local storage
Inheriting constructors
Rvalue references for *this
Minimal support for garbage collection
Don’t know
看起来GCC正取代Clang成为最支持C++11的编译器。Visual Studio已经增加了好几个重要C++11特性,像变参模板,初始化器和原生字。
I can’t really comment on how complete and bug-free these implementations are at a more fine grained level (other than VS2012 – I detail a lot of the bugs in the initial VS2012 release in my book, ).
It’s also useful to look at the state of library support. I’m not going to get very specific as there are lots of small changes across the standard library. I’m also going to omit Intel’s library from this comparison.
I can say that the major additions to the library are mostly provided by all three implementations (as shown in the table below), although with various caveats.
我真的不能在一个更为细致的层面去评论这些编译器实现到底完成得怎样,还有没有bug。(除了VS2012——我在我的书(《》)里详细列出过VS2012最初版本的大量bug)。
看下库的支持情况也是比较有用的。由于各编译器对标准库的支持都有较多小改动,我并不打算对此给出详细的细节。我也打算在这次的比较中省略Intel的库。
我可以说,这些库的主要附件大多由第三方实现提供(随后在下面的表格中展现),尽管这是有各种各样的警告。
Microsoft’s library implementation lacks anything that requires unimplemented language features such as constexpr (as of the initial release of VS2012). The library hasn’t been updated to use the features in the November 2012 CTP of the compiler such as initializer lists or variadic templates.
GCC’s libstdc++ lags somewhat as it doesn’t support regular expressions and low-level concurrency features. It also doesn’t implement constexpr methods in a lot of cases.
微软的库实现中没有那些需求尚未被实现的语言功能的东西,例如 constexpr(如VS2012的最初发行版)。库文件还没有更新,以支持2012年11月在 CTP 提出的编译器功能,如初始化列表和可变参数模板。
GCC 的 libstdc++ 也有些滞后,例如它并不支持正则表达式以及地称并发功能。同样,在很多情况下,它也没有实现 constexpr 方法。
Clang’s libc++ is 100% complete on Mac OS, however various parts of it don’t yet work on Windows and Linux.
Concurrency: async/future/promise/packaged_task
Concurrency: thread and related
Concurrency: condition variables
Concurrency: mutexes
Concurrency: atomic types and operations
Concurrency: relaxed memory ordering and fences
Smart pointers
std::function
Regular expressions
Type traits
std::forward_list
std::array
Hash tables
Random number generation
Compile time rational numbers (ratio)
Time utilities (chrono)
Initializer lists
Diagnostics (system_error)
STL refinements and new algorithms
General purpose (move, forward, declval etc.)
It’s good to see that the language and library support is steadily improving. Clang and GCC are getting close to having full C++11 support. Visual Studio is also improving C++11 support, and I’m pleased that C++ compiler updates are happening between major releases. The list of supported features in Intel’s compilers is growing longer as well.
Who knows, by next year all four compilers might support all the C++11 features!
Clang的libc++是100%兼容MacOS的,但是它有部分的特性还不兼容Windows和Linux。
Concurrency: async/future/promise/packaged_task
Concurrency: thread and related
Concurrency: condition variables
Concurrency: mutexes
Concurrency: atomic types and operations
Concurrency: relaxed memory ordering and fences
Smart pointers
std::function
Regular expressions
Type traits
std::forward_list
std::array
Hash tables
Random number generation
Compile time rational numbers (ratio)
Time utilities (chrono)
Initializer lists
Diagnostics (system_error)
STL refinements and new algorithms
General purpose (move, forward, declval etc.)
比较高兴的是能看到语言和库的支持在稳步改善。Clang和GCC距离完全支持C++11已经很近了。Visual Studio同样在改善对C++11的支持,令我感到欣慰的是C++编译器的更新都是在主分支上。这份Intel的编译器特征支持列表也越来越多。
谁知道明年这4个编译器会不会全部支持C++11的特征呢!C/C++(22)
C++11(13)
英文原文:
距离我已经有大半年了。这次我来根据这些预览版的编译器的文档来看下它们是如何堆砌起来的。
GCC的下个版本是4.8,以及Clang即将到来的版本是3.3 。如果你使用Visual Studio 2012,你可以安装2012年11月更新支持C++11额外特征的体验版CTP。
&翻译的不错哦!
我也对V.13.0的Intel C++编译器感到好奇,虽然它还不是预览版并且我也找不到有关它的新特性的信息。我没找到任何有关这个即将发行版本的编译器的信息。
g++ 4.8
Intel 13.0
Rvalue references and move semantics
Lambda expressions
static_assert
Range based for loop
Trailing return type in functions
extern templates
&& for nested templates
Local and unnamed types as template arguments
Variadic macros
Variadic templates
Default template arguments in function templates
final method keyword
override method keyword
Strongly typed enums
Forward declared enums
Initializer lists
explicit type conversion operators
Raw string literals
Forwarding constructors
Template aliases
Defaulted methods
Deleted methods
New built-in types
Alignment support
Inline namespaces
sizeof on non-static data members without an instance
Changed restrictions on union members
User defined literals
Encoding support in literals
Arbitrary expressions in template deduction contexts
Don’t know
Non-static data member initializers
Don’t know
C99 compatibility
Generalized attributes
Thread local storage
Inheriting constructors
Rvalue references for *this
Minimal support for garbage collection
Don’t know
看起来GCC正取代Clang成为最支持C++11的编译器。Visual Studio已经增加了好几个重要C++11特性,像变参模板,初始化器和原生字。
&翻译的不错哦!
我真的不能在一个更为细致的层面去评论这些编译器实现到底完成得怎样,还有没有bug。(除了VS2012——我在我的书(《》)里详细列出过VS2012最初版本的大量bug)。
看下库的支持情况也是比较有用的。由于各编译器对标准库的支持都有较多小改动,我并不打算对此给出详细的细节。我也打算在这次的比较中省略Intel的库。
我可以说,这些库的主要附件大多由第三方实现提供(随后在下面的表格中展现),尽管这是有各种各样的警告。
&翻译的不错哦!
微软的库实现中没有那些需求尚未被实现的语言功能的东西,例如 constexpr(如VS2012的最初发行版)。库文件还没有更新,以支持2012年11月在 CTP 提出的编译器功能,如初始化列表和可变参数模板。
GCC 的 libstdc++ 也有些滞后,例如它并不支持正则表达式以及地称并发功能。同样,在很多情况下,它也没有实现 constexpr 方法。
&翻译的不错哦!
Clang的libc++是100%兼容MacOS的,但是它有部分的特性还不兼容Windows和Linux。
libstdc++
libc++
Concurrency: async/future/promise/packaged_task
Concurrency: thread and related
Concurrency: condition variables
Concurrency: mutexes
Concurrency: atomic types and operations
Concurrency: relaxed memory ordering and fences
Smart pointers
std::function
Regular expressions
Type traits
std::forward_list
std::array
Hash tables
Random number generation
Compile time rational numbers (ratio)
Time utilities (chrono)
Initializer lists
Diagnostics (system_error)
STL refinements and new algorithms
General purpose (move, forward, declval etc.)
比较高兴的是能看到语言和库的支持在稳步改善。Clang和GCC距离完全支持C++11已经很近了。Visual Studio同样在改善对C++11的支持,令我感到欣慰的是C++编译器的更新都是在主分支上。这份Intel的编译器特征支持列表也越来越多。
谁知道明年这4个编译器会不会全部支持C++11的特征呢!
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:48415次
排名:千里之外
原创:15篇
转载:147篇
(1)(2)(4)(1)(3)(6)(2)(8)(11)(27)(28)(26)(30)(6)(8)怎么让clang3.2支援c++11 - QT开发当前位置:& &&&怎么让clang3.2支援c++11怎么让clang3.2支援c++11&&网友分享于:&&浏览:27次如何让clang3.2支援c++11?刚在mac&mini上安装Qt4.8.4
qmake和clang3.2好不容易装上去后
却发现clang3.2不支援C++11
clang3.2的binary
http://llvm.org/releases/download.html
下载之后直接解压缩
#-------------------------------------------------
#&Project&created&by&QtCreator&T07:23:32
#-------------------------------------------------
QT&&&&&&&+=&core&gui
greaterThan(QT_MAJOR_VERSION,&4):&QT&+=&widgets
TARGET&=&test00
TEMPLATE&=&app
CONFIG&+=&-std=gnu++11
SOURCES&+=&main.cpp\
&&&&&&&&mainwindow.cpp
HEADERS&&+=&mainwindow.h
FORMS&&&&+=&mainwindow.ui
#include&&functional&
#include&&iostream&
#include&&memory&
#include&"mainwindow.h"
#include&&QApplication&
int&main(int&argc,&char&*argv[])
&&&&QApplication&a(argc,&argv);
&&&&MainWindow&w;
&&&&w.show();
&&&&auto&A&=&444;&//警告,&
&&&&std::cout&&A&&std::
&&&&std::unique_ptr&int&&B;&//错误讯息
&&&&return&a.exec();
auto'&type&specifier&is&a&C++11&extension&[-Wc++11-extensions]
错误讯息&:
error:&expected&'('&for&function-style&cast&or&type&construction
&&&&std::unique_ptr&int&&B
我在QtCreator设置的编译器,该执行档的名称是"clang"
------解决方案--------------------Clang&3.2&supports&most&of&the&language&features&added&in&the&latest&ISO&C++&standard,C++&2011.&Use&-std=c++11&or&-std=gnu++11&to&enable&support&for&these&features.
需要添加编译选项&-std=c++11&或&-std=gnu++11------解决方案--------------------mac&os里面默认自带的gcc版本较低
建议还是升级下
参见下面这篇文章
/questions/-on-mac-with-clang-or-gcc
/questions//clangs-support-of-c-11-lambda/64165------解决方案--------------------试试qmake,make看看编译期的参数和你设置的是否一致
引用:我没有升级gcc,改用system&path下的clang++编译(用XCODE下载了command&line&tools)
结果居然编译过关了
clang++&-stdlib=libc++&-std=c++11&main.cpp&-o&test
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有

我要回帖

更多关于 clang c header 的文章

 

随机推荐