使用unordered_map编译报#error This file requires compiler and library support
2015-07-24 13:22
11017 查看
最近常用到unordered_map,但是我发现这个库在vc6中不能用,无赖只好换成vs2012,测试可以用。然而,我在linux下用g++编译时,出现了以下错误:
In file included from /usr/include/c++/4.8/unordered_map:35:0,
from cul.cc:3:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
cul.cc: In member function ‘int Solution::lengthOfLongestSubstring(std::string)’:
cul.cc:15:4: error: ‘unordered_map’ was not declared in this scope
unordered_map<char,int> hash;
....
后面的信息可以看出,是说unordered_map没有定义,我在网上查找了下发现g++4.4之后都支持,我用的是4.8,应该可以正常使用的。最后看到这句:This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11
compiler options.发现时需要编译时加上-std=c++11这个参数,才可以使用,如下:
g++ -std=c++11 -g -o cu cul.cc
发现编译OK!!
In file included from /usr/include/c++/4.8/unordered_map:35:0,
from cul.cc:3:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
cul.cc: In member function ‘int Solution::lengthOfLongestSubstring(std::string)’:
cul.cc:15:4: error: ‘unordered_map’ was not declared in this scope
unordered_map<char,int> hash;
....
后面的信息可以看出,是说unordered_map没有定义,我在网上查找了下发现g++4.4之后都支持,我用的是4.8,应该可以正常使用的。最后看到这句:This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11
compiler options.发现时需要编译时加上-std=c++11这个参数,才可以使用,如下:
g++ -std=c++11 -g -o cu cul.cc
发现编译OK!!
相关文章推荐
- 关于HashMap根据Value获取Key
- 修正EasyUI的BUG——Form中存在FileBox时的数据加载错误
- PS快捷键大全
- javaGUI解决闪屏问题
- UICollectionView的简单使用
- IOS开发UI基础--数据刷新
- java GUI游戏界面问题 play,exit操作
- iOS8开发~UI布局(二)storyboard中autolayout和size class的使用详解 f
- POJ 2457--Part Acquisition 【spfa最短路 + STL路径输出】
- 如果你在iphone6plus下看到[UIScreen mainScreen].scale不是3.0
- Maven的Build过程
- [Java Web]EasyUI中Calendar预设时间的解决
- UITableView的简单使用
- IOS UILocalNotification 本地通知
- iOS 编程 利用UIScrollView 编写无缝循环显示图片
- 安卓使用merge标签和include优化UI布局
- uep开发——财务管理系统的总结
- 如何扩展EasyUI在页面中立即显示选中的本地图片
- Implement Queue using Stacks
- gulp插件(gulp-jmbuild),用于WEB前端构建