Re: sizeof(int)

From: Jack Klein (jackklein_at_spamcop.net)
Date: 02/28/05


Date: Sun, 27 Feb 2005 22:06:57 -0600

On Sun, 27 Feb 2005 09:53:01 -0500, Ron Natalie <ron@sensor.com> wrote
in comp.lang.c++:

> Shezan Baig wrote:
> > DHOLLINGSWORTH2 wrote:
> >
> >>A char is always 8 bits.
> >
> >
> >
> > Why can't a char be 16 bits?
> >
> It can be, but it is unlikely. Unfortunately one of the
> great defects in C++ is that char has a double role: that
> of the basic character AND that of the smallest addressable
> storage unit. Ideally, bytes and characters should be dissassociated.

Interesting. Just today I was working with an architecture where char
has 16 bits, which is indeed the smallest addressable storage unit.

What possible gain from defining a char as 8 bits when a byte is 16
bits? You can only store one char per byte, unless you use bit fields
or bit-wise operators to merge and separate them.

And there are platforms where char and in fact all the integer types
are 32 bits. Period.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html


Relevant Pages

  • Re: sizeof(int)
    ... > Shezan Baig wrote: ... >> Why can't a char be 16 bits? ... > of the basic character AND that of the smallest addressable ... > storage unit. ...
    (comp.lang.cpp)
  • Re: sizeof(int)
    ... >> of the basic character AND that of the smallest addressable ... >> storage unit. ... In C++ terms 'char' and 'byte' are interchangeable. ... said "octet", maybe. ...
    (comp.lang.cpp)
  • Re: bit order in xx-endian system
    ... the order of bitfields; 'h' could end up as the first bit or 'h' ... the size of the "storage unit" that is being filled up, ... unsigned char a:1; ... the int corresponding to the address of byte 1 -- as long as the ...
    (comp.lang.c)
  • Re: Something strange with g77 ...
    ... and quad for binary and decimal radices and there is some move ... A byte must hold a char, ... So when gcc (the C compiler, ... the size of the file storage unit, numerical storage unit, ...
    (comp.lang.fortran)
  • Re: sizeof(int)
    ... > Shezan Baig wrote: ... I think you misunderstand the role of a char WRT basic character set. ...
    (comp.lang.cpp)