Re: [问题] C++ std::to_string无法编译

楼主: suhorng ( )   2014-04-18 21:54:10
※ 引述《deangogi (绿教徒)》之铭言:
: 开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
: Code::Blocks 13.12
: 额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
: 问题(Question):
: 是这样的 我的程式内要用到std::to_string()
: 已经将compiler设定成支援c++11
: 可是编译时一直出现error: 'to_string' is not a member of 'std'
: 用google搜了一下 有人说是MinGW的问题
: 请问我在windows下有什么解决的方法吗 感谢> <
MinGW 4.7 基于一些跟 wchar_t 有关的理由(Windows不相容)把那整片区域都 #ifdef
掉了, 但其他无关的 code 事实上还是好的, 所以直接改 code 把 #ifdef 修掉就好:
印象中新版的 MinGW (GCC 4.8) 好像有修好..不过不太确定
在 MinGW\lib\gcc\mingw32\4.7.2\include\c++\bits 里面的 basic_string.h
搜寻 to_string 会看到一段被被包在 #ifdef 里面的 code,
把那 #ifdef 改掉(我这边是第2812行):
- 2811 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99) \
- 2812 && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
+ 2811 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99))
+ 2812 // && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
.....
+ 2961 #if (!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
+ 3023 #endif
http://stackoverflow.com/a/12975602/2013713
http://stackoverflow.com/questions/8542221/
作者: q82419 (q82419)   2014-04-18 22:31:00
<(_ _)>
作者: Hyww13 (hyww)   2014-04-18 22:54:00
推~(这问题跟回答有强烈的既视感XD
楼主: suhorng ( )   2014-04-18 22:56:00
lol
作者: deangogi (少林扫地僧)   2014-04-20 22:40:00
先用我帐号帮我弟问 结果他自己又去dsa发一篇

Links booklink

Contact Us: admin [ a t ] ucptt.com