c++ - Problems with std::stoi, not working on MinGW GCC 4.7.2 -
#include <iostream> #include <string> int main() { std::string test = "45"; int myint = stoi(test); std::cout << myint << '\n'; }
i tried code on computer running mingw gcc 4.7.2. gives me error:
what doing wrong, got cppreference. exact same code. , different error 1 described here.
it seems mingw needs patch: enabling string conversion functions in mingw
this patch enables following list of c++11 functions , templates in std namespace:
stoi, stol, stoul, stoll, stof, stod, stold, to_string, to_wstring
in above link, there .zip
file, download and
- copy wchar.h , stdio.h include directory in zip file following directory (overwrite): c:\mingw\include (replace c:\mingw\ appropriate directory)
- copy os_defines.h following directory (overwrite): c:\mingw\lib\gcc\mingw32\4.7.0\include\c++\mingw32\bits (replace c:\mingw\ appropriate directory) (replace 4.7.0 correct version number)
Comments
Post a Comment