C++ std::to_字符串不是C+中的成员+;11使用CygWin
我有以下代码C++ std::to_字符串不是C+中的成员+;11使用CygWin,c++,python-3.x,c++11,C++,Python 3.x,C++11,我有以下代码 // My.h #include <string> .... // My.cpp #include "My.h" ... errMsg = "X value [too low]: " + std::to_string(xInVal); 我得到以下错误 error: ‘to_string’ is not a member of ‘std’ errMsg = "X value [too low]: " + std::to_string(xInVal); 我遗漏
// My.h
#include <string>
....
// My.cpp
#include "My.h"
...
errMsg = "X value [too low]: " + std::to_string(xInVal);
我得到以下错误
error: ‘to_string’ is not a member of ‘std’
errMsg = "X value [too low]: " + std::to_string(xInVal);
我遗漏了什么?我如何用这种方式使用字符串?从CYGWIN头中,看起来对于C++11,这些没有定义,除非定义了
\u GLIBCXX\u use\u C99
,如果:
#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
我试着定义\u GLIBCXX\u USE\u C99
,但这对我的项目不起作用。您可以在使用字符串头之前尝试定义它
我最近在CYGWIN上遇到了一个与C++11类似的问题,涉及到
\uu STRICT\u ANSI\ucode>可能重复您使用的GCC版本(GCC--version
)?实际上,它甚至在CYGWIN GCC 5.2.0+stdlibc++5.2.0上也不起作用。我很惊讶@Jackie你可以自己实现,这没什么大不了的,或者切换到另一个Windows工具链:MSYS+MinGW-w64(修复)、Visual studio(不像以前那么糟糕,现在他们有独立的工具链,没有IDE)、Clang/C2(Clang frontend+microsoft codegen),英特尔等。唯一的问题是,如果你的应用程序使用autotools或Unix特定的头文件/libs之类的东西。@Drop谢谢。我试图查找如何修补它,但运气不太好。如果我退回到Unix虚拟机,它应该可以正常工作(或者至少没有这些问题)。我想我必须自己去学习其他的工具链。
#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)