2013-02-01 45 views
1

爲什麼不能在gcc上編譯?在libstdC++中使用std :: to_wstring?

#include <iostream> 
#include <string> 

int main() { 

    double f = 23.43;  
    std::wstring f_str = std::to_wstring(f); 
    std::wcout << f_str << std::endl; 

    return 0; 
} 

錯誤:

prog.cpp: In function ‘int main()’:

prog.cpp:6:26: error: ‘to_wstring’ is not a member of ‘std’

example

+0

你使用的是什麼版本的GCC和libstdC++? –

+0

你正在使用'-std = C++ 11'並定義'__GXX_EXPERIMENTAL_CXX0X__'? – antonijn

+0

@Antonijn,你不應該定義'__GCC_EXPERIMENTAL_CXX0X__',把它留給編譯器,不要這樣做。永遠不要這樣做。 –

回答

1

你的程序編譯,如果你選擇C++在IDEONE而不是C++中爲0x,因爲它具有C++ 11功能。

相關問題