lint, pointers, 0 (what else?)

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Wed Feb 6 18:52:57 AEST 1985


(void) is an operation.  Performing it when it is called for
should be no problem; apart from printf()/putc()/strcpy(),
one usually SHOULD test the return value of most functions.
I find very few occasions other than those just mentioned
when it is appropriate to discard the result of a function.
Explicit use of (void) precisely documents one's intention.

The /*<whatever>*/ lint pragmas are seldom needed in clean
code.  I find I need at most one every several hundred lines.

The reasons for not always having sizeof(char *) == sizeof(int)
have been explained several times.  The simplest examples I can
give are the Honeywell (CCC) x16 and the CDC 17xx which had 16-bit
words and were word-addressable.  To address all 128Kb (actually
less, due to chained indirect addressing) one would have to use
two words for a (char *), but only one for an (int *) or (int).
It would be absolute folly to use double words for the latter.

It is true that much code written in the days when there was only
one C compiler (Ritchie's, for the PDP-11) did not pay attention
to distinguishing among different data types, since the programmer
"knew" what the generated code would be.  Those days should have
ended with 7th Edition UNIX, when many of the portability features
were added to C (because they were needed, not because of any
academic concerns for coding purity).  Unfortunately Berkeley did
not help much with their 4BSD VAXisms (sizeof(int) == sizeof(long),
for example), although recently they have been better about this.

Just because one is using a machine with particular characteristics
is no reason to disparage those who wish their code to run, and run
well, across a wide variety of machines.  Go ahead and hack away in
your private little universe, but be aware why people at other
sites may not want to go through the trouble it would take to try
to use your code on their systems.



More information about the Comp.lang.c mailing list