-fsigned-char on all arches

Rob Landley rob at landley.net
Thu Apr 12 17:55:46 UTC 2007


On Thursday 12 April 2007 5:13 am, Will Newton wrote:
> On 4/11/07, Rob Landley <rob at landley.net> wrote:
> 
> > Because when it varies it's a source of bugs, and we got tired of hitting
> > them.  (And yes, we hit them.)
> 
> Are there any bugs in the bug database I could refer to?

I'm not the person to ask there, I don't really use the uClibc bug database.

> > You can specify "signed char" or "unsigned char" when you declare them, 
and
> > lots of places do.  But gcc 4.x produces warnings whenever things "differ 
in
> > signedness", and filling the code with typecasts to make this shut up 
would
> > make the code brittle and unreadable and eventually introduce new bugs
> > (because that thing you're typecasting to (signed char) got turned into an
> > unsigned int elsewhere and all the references that produced an error or
> > warning were fixed up, but the typecast prevents this one from
> > complaining...)
> 
> I count 10 warnings in 3 source files (all printf/scanf related).

To clarify: C strings are "char *", with no signed or unsigned specifier, and 
standards like POSIX say that headers have to use "char *" in a bunch of 
places.  If it wasn't for this, we could explicitly specify "signed" 
or "unsigned" every time we declared a char or char *, which would be exactly 
the same result but you wouldn't notice the compiler flag to complain about 
it.  So we specify it at the compiler flag level, to get consistent behavior.

You are welcome to modify the compiler flags in your personal copy.

> > BusyBox chose -funsigned-char because we liked being 8-bit clean.  (Makes
> > things like UTF-8 a whole lot easier).  But tinycc won't work if you build 
it
> > with -funsigned-char, which also means it won't work if you build it on an
> > architecture that defaults to -funsigned-char (arm, for example).  I 
haven't
> > tracked down the problem there yet...
>
> Is it valid to link a C library built with -fsigned-char with an app
> built with -funsigned-char?

As far as I know.  It's the same size and same endianness.  (I still lean 
towards unsigned because then you never have to check for <0 when doing 
things like isdigit(), but it wasn't my call...)

> > Which architecture are you referring to?
> 
> http://www.imgtec.com/metagence/products/

Never heard of it.

The "target architecture" menu of uClibc lists alpha, arm, bfin, cris, hppa, 
i386, ia64, m68k, mips, nips, nips2, powerpc, superh, sh64, sparc, vax, and 
x86_64.  It also lists the following as broken: v850, microblaze, i960, 
h8300, frv, and e1.

Which one are you referring to?

Rob
-- 
Penguicon 5.0 Apr 20-22, Linux Expo/SF Convention.  Bruce Schneier, Christine 
Peterson, Steve Jackson, Randy Milholland, Elizabeth Bear, Charlie Stross...



More information about the uClibc mailing list