Question

I'm trying to use any of the C++11 features in Orwell Dev C++ but with no luck. I installed the version with minGW and whatever I set in the compiler options, I just get the "[Error] 'to_string' was not declared in this scope" in this code:

#include<iostream>
#include<string>
using namespace std;

int main()
{
    string test = to_string(5);
}

I tried setting -std=gnu++11 and -std=c++0x but neither does the job. What's the most curious is that when I click on to_string, it shows me the overloaded functions - for long, float, int and so on. Thus, it must somehow get what the function does - how come it doesn't compile it, then? The compiler is set correctly to MinGW GCC 4.7.2 (the one bundled with the installer).

Was it helpful?

Solution 2

It is a known bug that to_string does not work with MinGW yet (which is actually GCC's fault, to a degree):

Intellisense is often driven by a different engine than the compiler (as very few compilers have hooks to make intellisense easy), so that's likely why you're seeing it in your IDE when it's not supported by your compiler.

OTHER TIPS

If you want to use C++11 in Dev-C++ you should to this steps:

  1. Go to Tools > Compiler Options
  2. Go to the tab Settings > Code Generation
  3. Change the parameter Language Standard (-std) to ISO C++11
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top