Style guides and portability

Paul D. Smith pds at lemming.webo.dg.com
Tue Jan 15 04:06:38 AEST 1991


[] In article <BEVAN.91Jan12120920 at orca.cs.man.ac.uk>, bevan at cs.man.ac.uk (Stephen J Bevan) writes:

[] > What about the cases where it is a requirement that a particular
[] > int MUST be able to hold 32 bit numbers.  If you transfer this to
[] > a 16 bit int system, your software is going to die horribly.

[] If the variable is required to hold 32 bit numbers, it should be a
[] long (which is guaranteed to be large enough) rather than an int.
[] I completely agree with Doug -- INT32 and friends are of no real
[] value.

At the risk of putting my foot in something unpleasant, I would like
to say I believe INT32 & friends *are* of real value.  Sure, right now
"long int" is 32 bits on any machine which supports it.  I firmly
believe that in the relatively near future 64-bit & above machines
will become a common reality.  I don't know what C, etc. will do to
support 64-bit integers, but I *do* know that whatever it is, I will
be able to port my code with at most a simple change of the type of
INT32.  It helps me sleep at night ... :-)

However, an even more important reason (IMHO) for the existence of
INT32 et.al. is that it tells you what is expected.  If you see a type
INT32 in the code, you say "he wants a 32-bit integer".  If you see a
"long int" in the code, you say "he wants a *big* integer".  In cases
where it is important that the number of bits == 32, or # of bits ==
16, or whatever (in networking software I find this to be a common
case), a type helps the reader see what is going on.

If you feel types such as "bool" are valuable as abstractions, then
why not INT32?  It is an abstracted name given to a quantity with
particular, defined uses and properties and is distinct (IMO) from a
simple "long int".

                                                                paul
-----
 ------------------------------------------------------------------
| Paul D. Smith                          | pds at lemming.webo.dg.com |
| Data General Corp.                     |                         |
| Network Services Development Division  |   "Pretty Damn S..."    |
| Open Network Systems Development       |                         |
 ------------------------------------------------------------------



More information about the Comp.lang.c mailing list