From: utzoo!decvax!cca!zrm.mit-ccc@Mit-Mc@sri-unix Newsgroups: net.unix-wizards Title: Re: Information on Unix/Vax peculiarities Article-I.D.: sri-unix.4755 Posted: Thu Dec 9 04:25:24 1982 Received: Fri Dec 10 07:45:49 1982 Date: 5 Dec 1982 14:58:45-EST Why should ints be as big as pointers? Not to write portable code. To do that the most commonly used hack is to use defined types to ensure that certain variables have sufficient resolution. The reason you want anything to fit into an int is that the compiler wants to minimise the contortions it would otherwise need to do to pass pointers to functions. On a pdp11 you have to go through some amount of hair to get longs and doubles in and out of functions. You would not want that to happen for every object larger than an int, especiallly pointers. See how simple things are on a VAX where ints, pointers, and longs are all the same size. In short, ints should be the same size as pointers not so much for the programmer's sake, but for the compiler implementer's. That C compilers do not try to "overcome" machine peculiarities is one of the advantages of C. There is an artifact in Unix that I do not knoe exactly how to interpret, but sems to indicate that, at one time, C could not pass objects larger than int to a function, or return them, or both. The function calls that deal with the date and time take a pointer to a long, rather than a long directly as an argument. I have not been hacking Unix for long enough -- is there someone out there who has been hacking it since v5 or so who might know why this peculiarity exists? Was it C in general or just Unix system calls that lose (or lost) in this way. Cheers, Zig