|
From: Andreas B. <be...@im...> - 2004-06-01 09:59:27
|
I have played a bit with wide characters under MinGW and got the
following results (gcc 3.4.0, mingw runtime 3.3):
(A) There seems to be at least partial support for wchar with plain C,
e.g. the following works:
-- file begin --
#include <stdio.h>
int
main(char *argv[], int argc) {
wprintf(L"hello world\n");
return 0;
}
-- file end --
(B) In C++ there seems to be no support for wide characters, i.e. the
following *does not* work, because neither wstring nor wcout
are defined:
-- file begin --
#include <iostream>
#include <string>
using namespace std;
int
main(char *argv[], int argc) {
wstring ws = wstring("hello world");
wcout << ws << endl;
return 0;
}
-- file end --
I have tried to re-compile libstdc++, which was quite difficult. When
using it, I am getting the following linker errors:
$ g++ wctest.cpp
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x3ee):ctype_members.cc:
undefined reference to `wctype'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x403):ctype_members.cc:
undefined reference to `wctype'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x418):ctype_members.cc:
undefined reference to `wctype'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x42d):ctype_members.cc:
undefined reference to `wctype'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x442):ctype_members.cc:
undefined reference to `wctype'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x454):ctype_members.cc:
more undefined references to `wctype' follow
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x788):ctype_members.cc:
undefined reference to `wctob'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x7fb):ctype_members.cc:
undefined reference to `wctob'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x845):ctype_members.cc:
undefined reference to `wctob'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x89f):ctype_members.cc:
undefined reference to `wctob'
/mingw/lib/libstdc++.a(ctype_members.o)(.text+0x8fc):ctype_members.cc:
undefined reference to `btowc'
/mingw/lib/libstdc++.a(numeric_members.o)(.text+0x66b):numeric_members.cc:
undefined reference to `btowc'
/mingw/lib/libstdc++.a(numeric_members.o)(.text+0x6b3):numeric_members.cc:
undefined reference to `btowc'
/mingw/lib/libstdc++.a(monetary_members.o)(.text+0xb1c):monetary_members.cc:
undefined reference to `btowc'
/mingw/lib/libstdc++.a(monetary_members.o)(.text+0xcd6):monetary_members.cc:
undefined reference to `btowc'
/mingw/lib/libstdc++.a(codecvt_members.o)(.text+0x15f):codecvt_members.cc:
undefined reference to `wcrtomb'
[... and so on ..]
This is pretty strange, because configure found out that 'btowc' and
'wcrtomb' are not available. This is from my "config.log":
[...]
ac_cv_func_btowc=no # <-- !!
ac_cv_func_copysignf=yes
ac_cv_func_fgetwc=yes
ac_cv_func_fgetws=yes
ac_cv_func_fputwc=yes
ac_cv_func_fputws=yes
[...]
ac_cv_func_getwc=yes
ac_cv_func_getwchar=yes
ac_cv_func_iconv=no
ac_cv_func_iconv_close=no
ac_cv_func_iconv_open=no
ac_cv_func_iswblank=no
ac_cv_func_mbrlen=no
ac_cv_func_mbrtowc=no
ac_cv_func_mbsinit=yes
ac_cv_func_mbsrtowcs=no
ac_cv_func_nl_langinfo=no
[...]
ac_cv_func_vwprintf=yes
ac_cv_func_vwscanf=yes
ac_cv_func_wcrtomb=no # <-- !!
ac_cv_func_wctob=no # <-- !!
[...]
Yes, I have taken a look into "gcc-3.4.0-build.sh" and I adopted the
configure flags that seemed to be applicable to libstdc++.
PLEASE, PLEASE: I would need further advice! How can I use wide
characters with C++?
Thanks,
Andreas
|