This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: wide chars with 16 BITS_PER_UNIT
- From: Richard Henderson <rth at redhat dot com>
- To: Thomas Gill <ned at tropic dot org dot uk>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 30 Mar 2007 09:52:22 -0700
- Subject: Re: wide chars with 16 BITS_PER_UNIT
- References: <20070330125912.GA7137@tropic.org.uk>
On Fri, Mar 30, 2007 at 01:59:12PM +0100, Thomas Gill wrote:
>
> Hi there,
>
> I maintain a GCC port for a small 16 bit processor called XAP2+. I'm
> having problems with strings of wide characters.
>
> I have the following defines, among others:
>
> #define BITS_PER_UNIT 16
> ...
> #define WCHAR_TYPE "int"
> #define WCHAR_TYPE_SIZE 16
>
> So, I'm expecting char and wchar_t to both be 16 bits wide.
I think the problem is that we've not told libcpp what the correct
narrow character set is. I suggest adding something like
if (BITS_PER_UNIT >= 32)
cpp_opts->narrow_charset = BYTES_BIG_ENDIAN ? "UTF-32BE" : "UTF-32LE";
else if (BITS_PER_UNIT >= 16)
cpp_opts->narrow_charset = BYTES_BIG_ENDIAN ? "UTF-16BE" : "UTF-16LE";
in a likely looking place in c_common_init_options. Then you
shouldn't have to do any translation in your output routines
at all.
r~