gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 23:14:16 27 4
gpt4 key购买 nike

我有以下代码...

// 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);

我遗漏了什么如何以这种方式使用 to_string?

最佳答案

从 CYGWIN 头文件来看,对于 C++11,这些文件似乎没有定义,除非定义了 _GLIBCXX_USE_C99 它们包含在其中,如果:

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

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

我最近在 CYGWIN 上遇到了与 __STRICT_ANSI__ 相关的 C++11 的类似问题

关于c++ - std::to_string 不是使用 CygWin 的 C++11 中的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34519061/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com