What breaks? (was Re: 64 bit longs?)

Henry Spencer henry at zoo.toronto.edu
Tue Jan 15 16:33:56 AEST 1991


In article <54379 at eerie.acsu.Buffalo.EDU> chu at acsu.buffalo.edu (john c chu) writes:
>>It is intuitively appealing, but I would be surprised to see anyone
>>implementing it:  it would break far too much badly-written software.
>
>Can someone please tell me what would break under that model and why?

There is an awful lot of crufty, amateurish code -- notably the Berkeley
kernel networking stuff, but it's not alone -- which has truly pervasive
assumptions that int, long, and pointers are all the same size:  32 bits.

At least one manufacturer of 64-bit machines has 32-bit longs and 64-bit
long longs for exactly this reason.

The problem can largely be avoided if you define symbolic names for your
important types (say, for example, net32_t for a 32-bit number in a TCP/IP
header) and consistently use those types, with care taken when converting
between them, moving them in and out from external storage, and passing
them as parameters.  This is a nuisance.  It's a lot easier to just treat
all your major types as interchangeable, but God will get you for it.
-- 
If the Space Shuttle was the answer,   | Henry Spencer at U of Toronto Zoology
what was the question?                 |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list