Re: What is the point of signed char?



"Peter Nilsson" <airia@xxxxxxxxxxx> writes:
> Lawrence Kirby wrote:
>> On Tue, 19 Jul 2005 05:10:55 -0700, ng5000 wrote:
>> > ...
>> > If I'm worried about space then I could use int8_t (from
>> > C99 stdint.h).
>>
>> If int8_t exists then char must be an 8 bit type on that system. It
>> is very likely that where it exists int8_t will be typedef'd as char
>> or signed char. ...
>
> I don't think that int8_t can be typedef'd as (plain) char in the
> strictest sense. C99 states that "int8_t denotes a signed integer
> type...", however plain char is not a signed integer type (per
> 6.2.5p4).
>
> That said, the 'as if' rule applies!

If you're correct that int8_t can't be typedef'ed as plain char, the
"as if" rule doesn't apply. The following would be illegal:

int8_t *iptr;
unsigned char *cptr;
cptr = iptr;

--
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: convert 16 bit port to Char
    ... way to save a 8-bit signed value found on the LSByte of PORTD to a CHAR. ... the lower byte of PORTD contains a signed integer that is 8-bits ... wide and I need to save it to a CHAR data type. ...
    (comp.arch.embedded)
  • Re: What is the point of signed char?
    ... >Lawrence Kirby wrote: ... >> If int8_t exists then char must be an 8 bit type on that system. ... C99 states that "int8_t denotes a signed integer ... as plain char is implementation defined. ...
    (comp.lang.c)
  • Re: What is the point of signed char?
    ... > If int8_t exists then char must be an 8 bit type on that system. ... C99 states that "int8_t denotes a signed integer ... however plain char is not a signed integer type (per ... Prev by Date: ...
    (comp.lang.c)
  • Re: convert a string to all-lowercase string
    ... I have an array of chars that I want to make all lower ... while (cPtr!= NULL) ... alpha character. ... implementations where char is signed, ...
    (comp.lang.c)
  • Re: convert a string to all-lowercase string
    ... int Scan ... while (cPtr!= NULL) ... alpha character. ... implementations where char is signed, ...
    (comp.lang.c)