c++ - to_string not declared in scope

c++ – to_string not declared in scope

c++ – to_string not declared in scope

There could be different reasons why it doesnt work for you: perhaps you need to qualify the name with std::, or perhaps you do not have C++11 support.

This works, provided you have C++11 support:

#include <string>

int main()
{
  std::string s = std::to_string(42);
}

To enable C++11 support with g++ or clang, you need to pass the option -std=c++0x. You can also use -std=c++11 on the newer versions of those compilers.

you must compile the file with c++11 support

g++ -std=c++0x  -o test example.cpp

c++ – to_string not declared in scope

I fixed this problem by changing the first line in Application.mk from

APP_STL := gnustl_static

to

APP_STL := c++_static

Related posts on c++ :

Leave a Reply

Your email address will not be published.