大峰98 2017-09-04 01:38 采纳率: 70%
浏览 2810
已采纳

gcc 中c++11的编译问题

我的是ubuntu下编译c++ primer plus的这么一段程序

#include
#include
using namespace std;
int main()
{
string str("abcd"):
for(auto c : str)
cout << c << endl;
}

报错提示如下:
warming:auto changes meaning in C++11;please remove it [-Wc++0x-compat]
error:c dose not name a type
warming:range-based for loop without a type-specifier only available with -std=c++1z or -std=gnu++1z

我觉得是不支持c++11的auto才引发的一系列错误,但是不知道如何改

  • 写回答

3条回答 默认 最新

  • wanwan_1996 2017-09-04 09:30
    关注
    LIBS = -std=c++11
    之后LIBS加入到编译项里面去
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?