#------------------------------------------------- # # Project created by QtCreator 2013-02-06T07:23:32 # #-------------------------------------------------
auto A = 444; //警告, std::cout<<A<<std::endl; 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版本较低 建议还是升级下 参见下面这篇文章 http://stackoverflow.com/questions/13958197/c11-on-mac-with-clang-or-gcc 和 http://stackoverflow.com/questions/13351032/clangs-support-of-c-11-lambda/13364165#13364165