错误:"stoi"未在此范围内声明(代码::Windows 10 上的块 16.01)
error: 'stoi' was not declared in this scope (Code::Blocks 16.01 on Windows 10)
我得到错误:"stoi"未在此范围中声明。
#include <string>
using namespace std;
...
int x;
x = stoi(arg[0]);
我在Windows 10上运行代码::块16.01,设置为-std=c++11。
我在这个页面上找不到任何有用的信息:未在此范围中声明"stoi">
我在某个地方看到升级gcc可以解决这个问题,但我在页面上没有找到合适的安装:https://mingw-w64.org/doku.php/download
同样的代码在Linux Mint 17.3上的code::Blocks 13.12中运行良好。
是否有针对此问题的建议修复程序?这可以通过使用64位版本的MinGW来修复吗(假设它与Code::Blocks 16.01兼容)?
更新有一个变通方法,使用atoi和c_str代替:
x = atoi(arg[0].c_str());
我认为这是MinGW的一个错误。有关更多信息,请查看这篇StackOverflow文章。特别是DRH的回答。
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux for Windows上编译C++代码时出错
- 在Windows上用C++裁剪HBITMAP
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- Windows/Cygwin - 不能使用 pybind11 - 犯错误
- Windows 10-使用gtkmm-3.0库和g++[包括再现]的分段故障
- 在Windows中以.exe的形式运行c++
- 为什么包含windows.h会产生语法错误,从而阻止类的实例化?(C2146,C2065)
- 无法在windows控制台中为C++程序提供必要的输入
- 在Windows中查找扬声器输出的当前音量级别
- Windows.h与GLFW.h的接口
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- Active Directory:从网络服务帐户下运行的Windows服务调用ADsOpenObject时失败
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 错误:"stoi"未在此范围内声明(代码::Windows 10 上的块 16.01)