0

I am using c++11 with MinGW compiler on code::blocks. When I type:

int x = stoi("4");

I get the error: 'stoi' was not declared in this scope, however it should be, and I can't figure out why it isn't.

This has been driving me up the wall, and I would love it if someone could help. Thanks a bunch :)

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Yaxlat
  • 665
  • 1
  • 10
  • 25
  • Older versions of g++ lacked that function. – Cheers and hth. - Alf Mar 16 '15 at 22:48
  • 2
    Did you `#include ` and say `using std::stoi`? – juanchopanza Mar 16 '15 at 22:49
  • This might help you - http://stackoverflow.com/questions/16132176/problems-with-stdstoi-not-working-on-mingw-gcc-4-7-2 – Sahil Nagpal Mar 16 '15 at 22:51
  • @user2760626 I tried that and it didn't work. – Yaxlat Mar 16 '15 at 22:54
  • @Alf do you know how I can update it? – Yaxlat Mar 16 '15 at 22:54
  • @Yaxlat: My latest MinGW g++ is 4.9.1 from the [Nuwen distribution](http://nuwen.net/mingw.html), and it has `stoi`. – Cheers and hth. - Alf Mar 16 '15 at 22:59
  • @Cheersandhth.-Alf Ok thanks a lot. Do you know how I can update it on code::blocks? – Yaxlat Mar 16 '15 at 23:02
  • @Yaxlat: You can just install it somewhere then configure code::blocks to use it. I know it's possible because I've done that in the past. However, note that with Nuwen you get static linking of runtime etc. by default, large executables, and you don't get support for various source encodings (only UTF-8). For more flexibility you may consider some older version from MinGW 64, or some other distribution, or, ask Ruben over in the C++ Lounge here on SO, if he's still there. – Cheers and hth. - Alf Mar 16 '15 at 23:05

0 Answers0