Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++11 to_string to working with code::blocks -std=c++11 flag already selected

Tags:

c++

gcc

c++11

stl

this is the code i am trying to compile, got it from another forum somewhere.

// to_string example

#include <iostream>   // std::cout

#include <string>     // std::string, std::to_string


int main ()

{

  std::string pi = "pi is " + std::to_string(3.1415926);

  std::string perfect = std::to_string(1+2+4+7+14) + " is a perfect number";

  std::cout << pi << '\n';

  std::cout << perfect << '\n';

  return 0;

}

I am getting the error: 'to_string' is not a member of 'std'

I have read in other forums to select the flags "Have g++ follow the c++11 ISO language standard [-std=c++11]" and i have and it still doesn't work.

Any help would be greatly appreciated

I am using the GNU GCC Compiler and code::Blocks 12.11

like image 552
Montana Avatar asked Nov 10 '13 19:11

Montana


1 Answers

MinGW-w64 added support for the necessary functionality since GCC 4.8, so make sure you are using at least version 4.8 GCC from MinGW-w64.

You can get one from here, although Code::Blocks should come with a TDM GCC toolchain which should work if it's the latest (because it's GCC 4.8.1 at the time of writing).

like image 54
rubenvb Avatar answered Oct 20 '22 02:10

rubenvb