0

this code:

#include <iostream>
#include <string>

int main()
{
    std::string s = "52123210";
    int derp = std::stoi(s, 0, 10);
    std::to_string(derp); 
    return 0;
}

with this error:

test.cpp:10:2: error: 'stoi' is not a member of 'std'

test.cpp:11:2: error: 'to_string' is not a member of 'std'

tried this:

http://tehsausage.com/mingw-to-string (not work)

Update my MingW from 4.6.1 to 4.8.1 (not work)

possible bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37522 (beyond of my knowledge to apply anything, I don't dare to touch the compiler's code)

**Also not work with "using namespace std" but produced 'stoi' and 'to_string' not declared error instead.

Vastor
  • 77
  • 1
  • 3
  • 12
  • possible duplicate of http://stackoverflow.com/questions/14755484/stoi-and-stdto-string-on-mingw-4-7-1 – Jarod42 Dec 22 '13 at 11:35

1 Answers1

0

This is a result of a non-standard declaration of vswprintf on Windows. The GNU Standard Library defines _GLIBCXX_HAVE_BROKEN_VSWPRINTF on this platform, which in turn disables the conversion functions you're attempting to use.

https://stackoverflow.com/a/8543540/2684539 proposes a hack/work around.

Community
  • 1
  • 1
Jarod42
  • 203,559
  • 14
  • 181
  • 302
  • found the solution before, tried on mingW 4.6.1, not work. tried again today, not work. – Vastor Dec 22 '13 at 13:59
  • either I change the code wrong, or it's just not work, i better reset all the change I made for the compiler's code. :/ – Vastor Dec 22 '13 at 14:00
  • @Vastor: else you can rewrite these methods. `to_string` with a `stringstream`, .. – Jarod42 Dec 22 '13 at 14:03