码迷,mamicode.com
首页 > 系统相关 > 详细

怎样在Linux环境编译支持C11

时间:2015-10-31 13:08:09      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

我用的系统是ubuntu 14.04, g++版本是4.8.4的,是支持C++11,我自己一般最常用的的C++编译器是g++和eclipse

一,g++

g++ 在一般的编译命令中加入-std=c++11 ,如下

g++ -std=c++11 -o test test.cpp

二,eclipse

打开eclipse,依次设置

C/C++ Build > Settings > GCC C++ Compiler > Miscellaneous > other flages 加 -std=c++11 或 c++0x

对于GCC C compiler, 相似的添加-std=gnu++11 然后点击 Apply。

如下程序可以测试是否,用C++11修改过的auto特性

  #include <iostream>
  using  namespace std;
  
  int main()
  {
      auto a = 10;
      cout << "%d\n",a;
      return 0;
  }

编译成功,即为设置成功.




怎样在Linux环境编译支持C11

标签:

原文地址:http://my.oschina.net/u/2280056/blog/524272

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!