作者suhorng ( )
看板C_and_CPP
標題Re: [問題] C++ std::to_string無法編譯
時間Fri Apr 18 21:54:10 2014
※ 引述《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/
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.229.106.24
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1397829253.A.0ED.html
推 q82419:<(_ _)> 04/18 22:31
推 Hyww13:推~(這問題跟回答有強烈的既視感XD 04/18 22:54
→ suhorng:lol 04/18 22:56
→ deangogi:先用我帳號幫我弟問 結果他自己又去dsa發一篇 04/20 22:40