gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnu-arch-users] hackerlab, tla, and `char' signedness


From: Ludovic Courtès
Subject: [Gnu-arch-users] hackerlab, tla, and `char' signedness
Date: Thu, 12 Jan 2006 15:18:51 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Hi,

Hackerlab and tla extensively use pointers to `t_uchar' to represent
strings.  However, `t_uchar' is different from `char' and unfortunately
C strings are of type pointer to `char' (not `signed char' nor `unsigned
char').  Therefore, we may get warnings such as "pointer targets differ
in signedness" (I do get them on PPC with GCC 4).

>From the GCC 4 manual:

  `-funsigned-char'
       Let the type `char' be unsigned, like `unsigned char'.

       Each kind of machine has a default for what `char' should be.  It
       is either like `unsigned char' by default or like `signed char' by
       default.

       Ideally, a portable program should always use `signed char' or
       `unsigned char' when it depends on the signedness of an object.
       But many programs have been written to use plain `char' and expect
       it to be signed, or expect it to be unsigned, depending on the
       machines they were written for.  This option, and its inverse, let
       you make such a program work with the opposite default.

       The type `char' is always a distinct type from each of `signed
       char' or `unsigned char', even though its behavior is always just
       like one of those two.

So I believe we should explicitly compile with `-funsigned-char'.

Thanks,
Ludovic.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]