This is the mail archive of the
mailing list for the GDB project.
RE: [RFA] Handle cygwin wchar_t specifics
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Tom Tromey'" <tromey at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Sat, 16 Apr 2011 18:05:19 +0200
- Subject: RE: [RFA] Handle cygwin wchar_t specifics
- References: <email@example.com> <firstname.lastname@example.org>
> -----Message d'origine-----
> De?: email@example.com [mailto:gdb-patches-
> firstname.lastname@example.org] De la part de Tom Tromey
> Envoyé?: vendredi 15 avril 2011 20:15
> À?: Pierre Muller
> Cc?: email@example.com
> Objet?: Re: [RFA] Handle cygwin wchar_t specifics
> >>>>> "Pierre" == Pierre Muller <firstname.lastname@example.org>
> Pierre> because of this, GDB uses "UCS-4LE"
> Pierre> for the macro INTERMEDIATE_ENCODING on Cygwin
> Pierre> (while "wchar_t" it uses for mingw32, which works well).
> Ok, I see the problem. I thought this:
> /* If __STDC_ISO_10646__ is defined, then the host wchar_t is UCS-4.
> But this is not true! For some values of __STDC_ISO_10646__, a 2 byte
> wide character type suffices. In particular, Cygwin's value of 200305
> means that it corresponds to Unicode 4.0.0:
> I think this might be a Cygwin bug, but it is pretty hard to wade
> through the ISO / Unicode differences and other assorted standardese to
> see. (The reason I think it might be a bug is that Unicode 4.0.0
> defines some characters > 0xFFFF.)
> Anyway, it doesn't matter if this is a Cygwin bug, since GDB's
> assumption here is wrong anyway.
> Pierre> The patch below fixes this by
> Pierre> explicitly setting the UCS size to two for Windows targets.
> I think in the __STDC_ISO_10646__ case, we should just explicitly use
> sizeof (wchar_t) somewhere to choose the intermediate encoding. I think
> this will be more robust than testing some host define.
Yes, but the problem is that it is not possible to use sizeof
inside a #if conditions :(
> Pierre> +#define wchar_size (&(((wchar_t) (0)) + 1) - &((char *) 0))
> This doesn't seem to be used.
I googled around to see if there is a workaround to this
limitation of not being able to use sizeof inside conditionals
and then forgot to remove it...
Do you know of any way to get the size of wchar_t?
I suspect we will need to add this to the configure scripts...
But I am still very bad on that part.
Help most welcome,