Re: 0xdeadbeef vs 0xdeadbeefL

From: Horst von Brand
Date: Thu Jul 08 2004 - 12:18:48 EST


tom st denis <tomstdenis@xxxxxxxxx> said:
> --- Gabriel Paubert <paubert@xxxxxxx> wrote:

[...]

> > On many platforms a "plain" char is unsigned. You can't write
> > portable
> > code without knowing this.
>
> Um, actually "char" like "int" and "long" in C99 is signed.

Nope. char is either an unsigned char or a signed char, which one is up to
the implementation, and the three types are distinct. The signed keyword
was introduced exactly for the corner case of an explicitly signed (not
unsigned, and not maybe signed) char.

> So while
> you can write
>
> signed int x = -3;
>
> You don't have to. in fact if you "have" to then your compiler is
> broken. Now I know that GCC offers "unsigned chars" but that's an
> EXTENSION not part of the actual standard.

Not an extension, in C for ever and ever.

> You ought to distinguish "what my compiler does" with "what the
> standard actually says". If you want unsigned chars don't be lazy,
> just write "unsigned char".

Right. Look at the standard, and then go back and rewrite to agree with C99
all the "standard conforming" C you have written. Should keep you away from
LKML for a while...
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/