Re: 0xdeadbeef vs 0xdeadbeefL

From: Horst von Brand (vonbrand_at_inf.utfsm.cl)
Date: 07/08/04

  • Next message: OGAWA Hirofumi: "Re: [PATCH] FAT: update document"
    To: tom st denis <tomstdenis@yahoo.com>
    Date:	Thu, 08 Jul 2004 13:16:25 -0400
    
    

    tom st denis <tomstdenis@yahoo.com> said:
    > --- Gabriel Paubert <paubert@iram.es> 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@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: OGAWA Hirofumi: "Re: [PATCH] FAT: update document"

    Relevant Pages

    • Putty key format.
      ... /* Hacked up ssh-add.c code to convert an OpenSSH key into a format ... static char *comment = NULL; ... int length; ... static unsigned char * buffer = NULL; ...
      (comp.security.ssh)
    • Patch - make config_max_raw_devices work
      ... increase the number of raw devices beyond 256 because during the char ... it uses the standard register_chrdevinterface which ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH][PPC64] lparcfg seq_file updates (pass 3)
      ... -static unsigned char e2a ... +static int lparcfg_data ... * General Public License for more details. ...
      (Linux-Kernel)
    • Re: Public disclosure of discovered vulnerabilities
      ... >> representable as an unsigned char or shall equal the value ... Manual/ disagreed with the standard, ... also for the value EOF ...
      (sci.crypt)
    • Re: Plain Char
      ... >about what the conversion of a char to unsigned char would mean, ... The origin of the mess is historical: the string handling functions ... any time you need a character ...
      (comp.lang.c)