Re: wide character/string support for pcc
Thorsten Glaser <tg <at> mirbsd.de>
2009-01-24 12:46:36 GMT
Gregory McGarry dixit:
> Currently, pcc defines WCHAR_TYPE in the arch-specific macdefs.h, which is
> clearly wrong, since it's a property of the C library. Your patch moves the
> definition into the configure script. However, it's not really a property of
> the OS.
Actually, it’s a property of the ABI. To simplify things, we assume there
are only two types of wchar_t – 16-bit and 32-bit – and do not really care
whether it’s signed/unsigned, int/long, etc. if it is (after all, we _are_
using Unicode code points here). wint_t is always 32 bit, due to promotion
rules.
However, MirBSD, glibc and (with my patch) pcc are the only operating en-
vironments I know of who define __STDC_ISO_10646__, so, while I agree that
the _size_ of wchar_t should be the same with pcc as it is with the native
compiler, the _semantics_ almost always do *not* match. This is by design.
> Is it appropriate to detect the type of wchar_t in configure.ac and set
> WCHAR_TYPE?
I don’t think so. We should define it “somewhere” – gcc/gcc/config/*.h is
the place where gcc does it, and I really don’t care if pcc defines it in
the macdefs.h file or via config.h, *BUT* the definition has to be visi-
ble in more places than macdefs.h can reach, so I’m all for the hardcoding
thing in configure, however much this is normally frowned upon.
Note that gcc has -fshort-wchar (mostly for Wine), but -fno-short-wchar
does not set the size to 32 bit if it had been 16 bit beforehand.
(Continue reading)