Header problems

Daniel A. Glasser dag at chinet.UUCP
Thu Mar 10 13:51:24 AEST 1988


Okay, I've now been flamed and roasted via mail, news and even on the
phone for my posting about NULL and 0.

If it were not for noisy and slow connections between the system I
do my posting from and where I actually am, I would have written
that to be the safest, you must cast NULL whenever you use it in a
call.  It was my recollection, and I did not have my K&R handy to
check it out when I posted my message, that the C specification in
K&R stated that when pointers to different objects had different
representations, all pointers were passed in the "universal" pointer
representation, just as char is promoted to int, float to double,
so would (foo *) be promoted to the equivilent of (void *), and then
moved back into a (foo *) representation when used at the other end.
Having delt with compilers that did this, I assumed that the language
had this orthoginality.  I'm sorry, I aplogise to everyone who's
life I have ruined with my posting.


I made my posting not out of a lust for power, but because in my
everyday work, I get about 3 calls a week passed to me from the
tech. support people where I work from customers who are porting
VAX unix code to the Atari ST using our compiler where ints are
16 bits, pointers 32 bits, and they often INSIST that K&R allows them
to use 0 or NULL without casts in function calls expecting pointers.
They get upset when I tell them that that is not the case.

If it makes you feel any better, I'll retract what I said.
However, the

	#ifndef ... #endif

or the

	#undef

should be used, and the EXPLICIT casting of any use of NULL in a parameter
list should be stressed.

<flame on>

Please note that of over 100 programs that I have gathered from the
network source groups, not one of them that I have actually looked at
has cast NULL to any kind of pointer when using it in calls.  Not one!
Not even the GNU stuff that I've looked at.

In other words, though proper usage uses casts on NULL, common usage
does not.

<flame off>
-- 
		Daniel A. Glasser	dag at chinet.UUCP
    One of those things that goes "BUMP!!! (ouch!)" in the night.
 ...!att-ih!chinet!dag | ...!ihnp4!mwc!dag | ...!ihnp4!mwc!gorgon!dag



More information about the Comp.lang.c mailing list