Re: Pointer arithmetic error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fre, 2008-06-27 at 11:01 -0700, Christopher Li wrote: 
> > In C, there is no type "byte" (unless you typedef oder #define it).
> > "byte" is usually (but not necessarily) meant as "unsigned char".
> 
> In C spec, there is a concept of "byte". The union return by sizeof()

I stand corrected. Hmm, I need the time to read C99 thoroughly.

> is byte. Char must fit in a byte. But char does not necessary have the
> same bits as byte. Char can have more.
> 
> C99: 3.6, 3.7.1
>
> Because char can always fit in byte, sizeof(char) == 1.

But how can a char have more bits than a byte?

> > IIRC C specifies that sizeof() returns values measured in chars, but
> > I don't believe it specifies any mapping between the size of chars
> > and the underlying addressing units --- it should be possible to use
> > 16-bit chars, for example, on an 8-bit byte system. > Using 32-bit
> > ints, sizeof(int) would then return 2; but you wouldn't be able to
> > access individual bytes from C.
> 
> sizeof() return value measure in _byte_.
> C99: 6.5.3.4

Yes. But "sizeof(char)" is always 1 (as stated in the same chapter). 
So I see no real difference between "byte" and "char" (at least with the
size of them).

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux