int8, etc.

Karl Heuer karl at haddock.ima.isc.com
Mon Jun 11 07:04:29 AEST 1990


In article <27.266bddfd at spanky.mgi.com> cepek at spanky.mgi.com writes:
>[What's wrong with a typedef `int8'?]

People who've used PL/I can probably give first-hand stories about why
explicit sizes are a bad idea.

If you were on a machine with 36-bit ints, 18-bit shorts, and 9-bit bytes,
what typedefs would you have?  If you define only `int9', `int18', and
`int36', then none of your code using `int8' will compile.  So I presume you
actually maintain a file of bitsize-typedefs `intNN' for all reasonable values
of NN.  But then why did you specify `int8' for the boolean type instead of
the more logical `int1'?  (Probable answer: since C requires that `char' be at
least 8 bits anyway, there's no need to distinguish anything smaller.  This
isn't entirely true, since an implementation on a bit-addressible machine
might provide a `short char' extension, and one should be able to take
advantage of that.)

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list