Andreas Beyer | 1 Jun 2004 11:59
Picon

wide character support

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;
(Continue reading)

Andreas Beyer | 3 Jun 2004 14:24
Picon

Re: wide character support

I had to continue my experiments (with gcc 3.4.0 and the respective c++ 
package).

Essentially two things are necessary to get full support of wstring:
(A) re-compile libstdc++
(B) bind with -lmsvsp60 (This is documented in "wchar.h" line 285.)

However, there are a number of issues:
Re-compiling libstdc++ required that I had to move all configure files 
from the gcc source directory one directory upwards before I could run 
configure in the libstdc++ sub-directory. (I.e. I had to copy files like 
install-sh from gcc-3.4.0-20040501-1/ to gcc-3.4.0-20040501-1/..)
I think this is a bug in libstdc++'s configure script.

Also, link order is important when using this newly compiled libtdc++. 
The attached example does *not* link if compiled as:
$ g++ -Wall wctest.cpp -lmsvcp60  # -> linker error

Instead the following works:
$ g++ -Wall wctest.cpp -lstdc++ -lmsvcp60
(Though, in this case you could also use gcc instead of g++.)

I don't see why there is no default support of wstring in mingw's 
libstdc++. It only has to be ensured that msvcp60 gets linked before 
libstdc++ and then everything works fine (at least with gcc 3.4.0). I 
suggest that future bin-packages of libstdc++ are compiled with wstring 
support and to change mingw32-g++ settings, such that it links msvcp60 
before libstdc++. This should provide at least basic support for 
wstring. I haven't tested all possible situations, but the attached 
example uses a few basic features that work fine.
(Continue reading)

Danny Smith | 3 Jun 2004 23:23
Picon

Re: wide character support


----- Original Message -----
From: "Andreas Beyer"

| I don't see why there is no default support of wstring in mingw's
| libstdc++. It only has to be ensured that msvcp60 gets linked before
| libstdc++ and then everything works fine (at least with gcc 3.4.0). I
| suggest that future bin-packages of libstdc++ are compiled with wstring
| support and to change mingw32-g++ settings, such that it links msvcp60
| before libstdc++. This should provide at least basic support for
| wstring. I haven't tested all possible situations, but the attached
| example uses a few basic features that work fine.

I don't think libstdc++ should depend on msvcp60.

To get wstring support to work simply do this to cwchar
(or to c/std_cwchar.h if working with sources)

*** cwchar.orig Thu Jun 03 22:06:11 2004
--- cwchar Thu Jun 03 22:04:24 2004
*************** namespace std
*** 137,143 ****
  #undef wprintf
  #undef wscanf

! #if _GLIBCXX_USE_WCHAR_T
  namespace std
  {
    using ::wint_t;
--- 137,143 ----
(Continue reading)


Gmane