2

I am trying to use std::to_string(), of course with #include <string>, but the compiler gives me the error that it was not declared in the scope, after lots of searching I have tried the fixes of going to compiler settings and have g++ follow... -std=c++11, downloading 4.7 patch header files for wchar.h, stdio.h, os_defines.h and re downloading the latest codeblocks version.

but nothing makes it seem to work.

what settings do I need to change to make this work.

#include <iostream>
#include <string>

using namespace std;
int main()
{
    string s=to_string(10);
    cout <<s<<endl;
    return 0;
}

update: I have re-installed codeblocks,version 13.12 tmd gcc, with gcc version 4.81(tmd-2), I have both -std=c++0 and -std=c++11 flags on in compiler settings, in Toolchain executables i have c++ compiiler:mingw32-gcc-4.8.1.exe, and it Still does not recognize to_string();

user3085497
  • 121
  • 2
  • 6

1 Answers1

3

I suppose you are using the Code::Blocks MinGW distribution which includes GCC 4.7.1. The MinGW implementation of libstdc++ does not support to_string, this is a known bug which cannot be fixed by simply patching the header files. Upgrade to the latest Code::Blocks version with GCC 4.8.1.

jasal
  • 1,044
  • 6
  • 14