在 C 裡面有 wchar_t
那麼在 C++ 應當也有對應的 container 才對
經查訪之後
應該是 wstring
於是就寫了一個小程式來測試一下
[cpp]
#include <iostream>
#include <string>
int main(int argc, char* argv[] ) {
wstring ws;
ws=wstring(“This is a test”);
cout << ws << endl;
}[/cpp]
但卻遭遇編譯失敗.
在看過 C++ 的 header 之後
發覺他把 wstring 的部分給 remark 起來了
所以我利用 grep 去找尋相關的部分
並做了一些修正如下:
- 將 string 中的 wstring 前頭的註解拿掉
- std/straits.h 134行 #if 0 改為 #if 1
std/cpp_type_traits.h 130行 #if 0 改為 #if 1 - 在 #include <string> 之前,要先
定義 __USE_ISOC99 或 __USE_UNIX98 (但#define __USE_UNIX98 會使得 pthread 有誤)
然後再 #include <cwchar> #include <cwctype>
結果呢
還是不行
真是傷腦筋~~
也許是因為雖然我用的是 gcc3 ,但header檔卻是 2.96 的緣故吧~