Re: gcc 4 signed vs unsigned char



juanitofoo@xxxxxxxxx writes:
> I thougth that using int8_t would be more portable. Anyway, in my code
> I also use int8_t, int16_t, int32_t (and their unsigned versions)
> instead of using int, short, long ... Should I use the intx_t or the
> int, short, etc? My main aim is portability among platforms.

Use whatever type is appropriate to your task. If you need an 8-bit
2's-complement type with no padding bits, use int8_t (assuming you
have a C99 implementation) -- but chances are you don't really need
all those properties.

If you need a signed type that's at least 16 bits, use int_least16_t.
Or use int.

And if you need to represent characters, use char; that's what it's
for.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: Boost process and C
    ... Using size_t is also not any more *portable* than using int. ... of portability is merely a reflection of the lack of the intrinsic ... I've gotten plenty of feedback over its lifetime which has ... "Cursed with non-portabilities" indeed ... ...
    (comp.lang.c)
  • Re: Basic questions
    ... The compiler is allowed to insert padding bits wherever it likes ... > As 16 is an int, what you wrote is equivalent to ... if the OP uses 'unsigned short' only to store 16-bit numbers (writing ... values, so they're not a panacea for portability, and they might trick ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Moving from C++ to VC++
    ... If you care about ... not some abstract notion of portability. ... probably still sit on 8bit 'int'. ... > size, index, or anything having to do with capacity in a data structure, ...
    (microsoft.public.vc.language)
  • Re: C99 exact width integers usage - informal survey
    ... so you can write perfectly portable code (assuming ANSI ... yes and no on the portability issue. ... types int and unsigned int. ... That's why the exact sized int types are not required in C99 unless ...
    (comp.arch.embedded)
  • Re: Future FASMLIB website
    ... C only allows three definitions for "int", ... count on long long because we aren't guaranteeing to the assembly ... though portability across different libraries under ... Assembly programmers will be explicitly familiar with the architechture ...
    (alt.lang.asm)