R
Randy Yates
Chris Hills said:Randy Yates said:In Harbison and Steele's text (fourth edition, p.111)
it is stated,
The C language does not specify the range of integers that the
integral types will represent, except ot say that type int may not
be smaller than short and long may not be smaller than int.
They go on to say,
Many implementations represent characters in 8 bits, type short in
16 bits, and type long in 32 bits, with type int using either 16 or
32 bits depending on the implementation. ISO C requires
implementations to use at least these widths.
If the C language is not defined by ISO C, then what defines it?
In reality the answer is quite simple. The users define the language....
That is to say various organisations produce compilers. These are used
by the SW community. Some become dominant in certain fields. ie PC, MAC,
Unix, 8051, AVR, PIC. These dominant compilers are effectively "the
standard" for that area. Most have extensions and some restrictions to
the ISO language .
You will often see the term "NQC" used here. It stands for "Not Quite C"
It refers to the many implementations of C, often for some of the
smaller 8/16 embedded architectures, that are literally Not Quite [ISO]
C but are the "standard" C for that field of work or particular
processor.
When C was originally devised, as commented on in this thread, there
were many machines with sizes that were not 8/16/32. No one was really
sure where things were going so the language was not restricted. Besides
there is not point in gratuitously breaking current code bases.
Thanks, Chris.
As time goes on I expect that 99.999% of new processors will have the
nice 8/16/32/64 bit system but there are many systems out there with a
good few years of life in them that don't conform to this.
True. TI's latest fixed-point, low-power digital signal processor family,
the TMS320C55xx, has a minimum wordlength of 16 bits, so a "byte" (a
sizeof(char)) is 16 bits.
The ISO-C standard is the goal to which the core of all compilers should
aim for. It is also the specification that they should list deviations
from. The fact that a compiler does not conform is usually not important
as long as you know that it does not and of course how it does not. In
many fields portability is not a prime, or even major, consideration.
Yeah, I knew all of this. I had just made the statement the other day
in comp.dsp that an int could be any size when someone stated that
they must be at least 16 bits. Then when I opened my H&S to clarify I
got even more confused. I was pretty sure that in the past (WAY
pre-ISO-C) you could have any damn size int you wanted.
--
% Randy Yates % "Though you ride on the wheels of tomorrow,
%% Fuquay-Varina, NC % you still wander the fields of your
%%% 919-577-9882 % sorrow."
%%%% <[email protected]> % '21st Century Man', *Time*, ELO
http://home.earthlink.net/~yatescr