std::to_string不是使用CygWin的C++11中的成员

std::to_string not a member in C++11 using CygWin

本文关键字:C++11 CygWin 成员 to string std      更新时间:2023-10-16

我有以下代码。。。

// My.h
#include <string>
....
// My.cpp
#include "My.h"
...
errMsg = "X value [too low]: " + std::to_string(xInVal);

但当我像。。。

//setup.py
extra_compile_args =['-std=c++11']
//console output
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python3/python3-3.4.3-1.x86_64/build=/usr/src/debug/python3-3.4.3-1 -fdebug-prefix-map=/usr/src/ports/python3/python3-3.4.3-1.x86_64/src/Python-3.4.3=/usr/src/debug/python3-3.4.3-1 -I./My -c ./My.cpp -o build/temp.cygwin-2.2.1-x86_64-3.4/./My.o -std=c++11

我得到以下错误。。。。

 error: ‘to_string’ is not a member of ‘std’
   errMsg = "X value [too low]: " + std::to_string(xInVal);

我错过了什么?我该如何使用这种方式响铃?

从CYGWIN标头来看,似乎对于C++11,除非定义了_GLIBCXX_USE_C99,否则不会定义它们。它们包含在if:中

#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)

我尝试定义_GLIBCXX_USE_C99,但这对我的项目不起作用。您可以在使用字符串标头之前尝试定义它。

我最近在CYGWIN上遇到了一个与__STRICT_ANSI__ 有关的类似问题