Codeblocks编译C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
来源:互联网 发布:python 中文字符串 编辑:程序博客网 时间:2024/06/07 04:09
原文链接:Enabling string conversion functions in MinGW
C++在将整型、浮点型、长整型等数据类型转换为字符串时,可使用<string>头文件包含的函数:to_string()!然而在codeblocks等编译环境中,有时候会出现 to_string was not declared in this scope等问题,原因是MINGW编译器不支持to_string()这个方法,这其实可以看成它的一个bug。
解决方法(以codeblocks为例):
1.首先你要使用to_string()这个函数,必须让编译器支持C++11的标准,因为这个函数是C++11提出的。当然不同版本在codeblocks中使用C++11标准,安装及配置方法不尽相同。【参考这里提供的安装方法一】下面给出两种不同版本下的处理(大体相似,只是去找的位置不同)。
法一:在CodeBlocks > Settings > Global compiler settings > Compiler Flags 中 勾选 Have g++ follow the C++11 ISO C++ language standard,然后点击下方的OK。(如果你的CodeBlocks没找到这个地方,参考下面的方法)
法二:点击CodeBlocks > Settings >global compiler settings如图: 至此安装及配置C++11标准完成。
2.下载提供的链接中mingw-to-string-gcc47.zip 这个压缩包。
3.将压缩包解压后,复制wchar.h和stdio.h到你的codeblocks安装路径中的\mingw\include中,将它们替换掉。再将os_defines.h复制到\mingw\lib\gcc\mingw32\4.x.x\include\c++\mingw32\bits即可运行。
【附:一文一图】
阅读全文
0 0
- Codeblocks编译C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- error: ‘to_string’ was not declared in this scope
- Qt中 error: 'to_string' is not a member of 'std'解决方法
- Android NDK编译C++ 'stoi' and 'to_string' is not a member of 'std'
- error: ‘to_string’ is not a member of ‘std’———已解决
- Dev-C++ “to_string is not a member of std” error- 已解决
- error: ‘exit’ was not declared in this scope 的解决方法
- error: ‘exit’ was not declared in this scope 的解决方法
- error: ‘exit’ was not declared in this scope 的解决方法
- ‘hash_map’ was not declared in this scope的解决方法
- error: ‘exit’ was not declared in this scope 的解决方法
- 关于g++ memcpy’ was not declared in this scope解决方法
- [编译错误]:exit was not declared in this scope
- ardupilot编译出错:'__builtin_bswap16' was not declared in this scope
- 安装fcgi时出现:error: ‘EOF’ was not declared in this scope解决方法
- ‘cout’ was not declared in this scope
- 'wxCHANGE_DIR' was not declared in this scope
- 单链表逆置
- Tyvj1037
- SVM-支持向量机学习(3):线性SVM
- hdu2102 A计划【BFS】
- java中的compareto方法的详细介绍
- Codeblocks编译C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- Smooth_L1_Loss函数的计算方式
- JieCaoVideoPlayer
- 习题5-4 交换学生(Foreign Exchange, UVa 10763)
- websphere缓存
- [Torch7]的安装
- C#+VS2012图片二进制流与数据库MySql、水晶报表间的操作(一)
- 51Nod 1006 最长公共子序列Lcs (输出)
- 【洛谷1967】【NOIP2013】货车运输