To_String Is Not a Member of Std, Says G++ (Mingw)

to_string is not a member of std, says g++ (mingw)

This is a known bug under MinGW. Relevant Bugzilla. In the comments section you can get a patch to make it work with MinGW.

This issue has been fixed in MinGW-w64 distros higher than GCC 4.8.0 provided by the MinGW-w64 project. Despite the name, the project provides toolchains for 32-bit along with 64-bit. The Nuwen MinGW distro also solves this issue.

to_string isn't a member of std?

you may want to specify the C++ version with

g++ -std=c++11 tmp.cpp -o tmp

I don't have gcc 4.8.1 at hand , but in older versions of GCC,
you can use

g++ -std=c++0x tmp.cpp -o tmp

At least gcc 4.9.2 I believe also support part of C++14 by specifying

g++ -std=c++1y tmp.cpp -o tmp

Update:
gcc 5.3.0 (I am using the cygwin version) supports both -std=c++14 and -std=c++17 now.

Why is this program giving an error: to_string is not a member of std. Why?

Those errors could mean:

  1. std::to_string requires header, which you did not include (but it doesn't)
  2. You didn't enable C++11 (I don't know how this works for Visual Studio)
  3. You compiler does not support C++11.

From comments it seems that Visual Studio you are using does not support C++11, so you can use old good string stream and with template you can create an equivalent of std::to_string:

#include <sstream>
#include <string>

template<class T>
std::string toString(const T &value) {
std::ostringstream os;
os << value;
return os.str();
}

//Usage:
std::string valueStr = toString(10);
valueStr.append(toString(1));
valueStr.append(toString(2.5));

Note that to use this function type T needs to have operator<< defined, but it's not a problem with types, which std::to_string supports.

Centos7 g++ to_string is not in a member of std

I believe what you are missing is a compiler flag -std=c++11 since std::to_string is introduced in C++11 version of the standard.

In the older versions of GCC you can use -std=c++0x for C++11 or -std=c++1y for C++14.

Function to_string() was not resolved using g++ mingw--w64 5.3.0

Eclipse was looking in System32 for the library and driver files, despite PATH and Eclipse pointing to the MingW64 compiler on the computer. Eclipse is also showing it is linked to the MingW64 libraries correctly as the path to the headers when right-clicking and opening deceleration is shown to be correct. Why then it looks in System32 for the library at run-time I don't understand.

The problem was 'solved' by copying the entire MingW64 compiler driver folder into the System32 folder on Windows.

Error: ‘to_string’ is not a member of ‘std’ when compiling in command line with gcc 4.8.2, works in NetBeans?

I think your problem is the order in which you're passing command line arguments to gcc

g++ -isystem -std=c++0x ~/gtest-1.7.0/include ...
^^^^^^^^^^^^^^^^^^^

The -isystem flag should be followed by a path that contains headers which you want gcc to treat as system headers. So the -std=c++0x flag is being incorrectly consumed by the -isystem flag. You probably want the command line to be

g++ -std=c++0x -isystem ~/gtest-1.7.0/include ...


Related Topics



Leave a reply



Submit