codeblock支持C++0x的设置

来源:互联网 发布:热处理加工数据 编辑:程序博客网 时间:2024/05/29 02:02

ubuntu:

1.Settings->complier and debugger->Global compiler settings找到other options 

2.输入-std=c++0x -U__STRICT_ANSI__

就可以 我是在下测试成功 貌似要更新G++使它支持c++0x

参考http://stackoverflow.com/questions/6528595/how-can-i-get-codeblocks-to-compile-with-std-c0x-with-gcc

windows:

1.安装最新版本的MinGW

2.Settings->complier and debugger->Global compiler settings 找到toolchain executabels 将编译器地址选择为你刚才安装的MinGW的地址


3.Settings->complier and debugger->Global compiler settings找到other options    输入-std=c++0x -U__STRICT_ANSI__ 


备注:MinGW下载http://sourceforge.net/projects/mingw/files/latest/download?source=files 安装的时候选择Download latest repository catalogues

3.vc2005 设置外部扩展工具之后 要修改系统的环境变量 我的电脑->属性->高级->环境变量 系统变量中找到path编辑把g++所在的文件地址添加进去D:\MinGW\bin

  

测试代码

#include<iostream>  using std::cout;//#include<vector>  using std::vector;//template< typename T >void tout( const T &vec ){  //自动推断类型  cc11 标准特性  for( auto pos = vec.begin(); pos not_eq vec.end(); ++pos ) cout << *pos << '\t';  return;}int main(){  vector<int> ivec={ 1, 2, 3 };//使用字面数组初始化 vector cc11 标准特性  tout( ivec );//  cout << '\n';//return 0;}