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