compilation warnings: 'pointer targets ... differ in signedness'

Larry Doolittle ldoolitt at recycle.lbl.gov
Thu Oct 6 13:05:38 PDT 2005


Rob -

On Thu, Oct 06, 2005 at 02:06:24PM -0500, Rob Landley wrote:
> On Tuesday 04 October 2005 13:23, Larry Doolittle wrote:
> > [chop] So in 99% of our uses, busybox should leave 
> > [the signed-ness of char] unspecified.
> 
> By that logic, short and int should also be of indeterminate sign.

Except that software more regularly does arithmetic with
short and int.  chars are typically copied, and compared
for equality, and that's it. [1]

> > Blanket declaration of all chars as unsigned (or signed, for that
> > matter) is, well, counter to the philosophy of C.
> 
> The philosophy of C?

... as normally espoused on comp.lang.c.

> Keep in mind that this mess originated from machines that had chars as long as 
> 4 bytes.  Is depending on char to be 1 byte also counter to the philosophy of 
> C?  (We do that in _lots_ of places.)

C has no notion of 'byte', only char.  There are lots of machines
out there that have a 16 or 32 bit char, even today -- and they
are not considered oddball. [2]

IMHO, busybox should stick to ANSI/ISO C when possible, and document
when additional assumptions are needed (or even desired to save on
code size).  If you see code that would break on a 16-bit char machine,
consider adding
#if UCHAR_MAX > 255
#error this code not qualified for your machine
#endif
to that C file, rather than wait for it to break at run time.

> I only really care if new compilers start spitting out fresh warnings.  I'm 
> still using gcc 3.3 on my laptop, but plan to upgrade before too long.

gcc-4.0 branch is a lot noisier than before.  Some of the
new noise is even useful.  ;-)

       - Larry

[1] I was going to add the exception "and add unsigned integers
that are provably less than 10 to '0'."  But '0' is actually of
type int, so that's not an exception.  The only assumption is
that the integer values for '0' through '9' can be converted to
type char correctly.

[2] I wouldn't be surprised to see an increasing number of
these machines, in the name of internationalization and wide
characters.  Inability to address octets has been the traditional
realm of supercomputers and DSP architectures.  Hmmm, I wonder how
hard it would be to port Linux or netBSD to one of these machines?
Cray used a Unix variant called UNICOS.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://busybox.net/lists/busybox/attachments/20051006/27c4e86e/attachment.pgp


More information about the busybox mailing list