uustatus - realtime uustat for HDB uucp (w/findpath)

William E. Davidsen Jr davidsen at steinmetz.ge.com
Mon Jan 30 23:21:24 AEST 1989


In article <1989Jan30.013936.11995 at gpu.utcs.toronto.edu> woods at gpu.utcs.Toronto.EDU (Greg Woods) writes:
| 
| What I'm about to say is really just a flame, but at the same time, I
| don't want to start a war either.  This is posted, instead of being
| mailed, out of general frustration at a very obvious mis-understanding
| that has perpetuated itself for far too long.

  What I am going to say is a flame, too. The ANSI standard for C says
that NULL will return a pointer constant. Not an integer constant,
*pointer*. Section 4.1.5, line 4, page 96. Please stop posting your
opinion as fact. What you mean is that K&R used NULL and you wish it
hadn't changed. Anyone who writes portable code never assumes integet
*or* pointer, but casts it as needed and uses zero when they mean zero.

| The reason your compiler gives you a warning message, is because NULL
| has been erroneously defined as something other than just plain zero.  I
	See above. "Erroneously defined" to meet the ANSI standard.
| most definitely will not go into the reasons why, but it should suffice
| to say that "#define NULL 0" is the only correct definition.  [Anyone
	It should suffice to say that you are wrong.
| who would like some evidence, please send me some mail.]
| 
| The only unfortunate side-effect of this is the potential breaking of
| any programmes that were written with the assumption that NULL is
| defined as something other than zero.
	Correct! Older programs which used NULL as if it were zero will
fail under ANSI compilers. So will Pascal programs. They are not 100%
compatible, although it is possible to write in that set of features
shared by K&R and ANSI.
| 
| As another point of warning, be careful of the Microsoft C iAPX86
| compiler that you are most likely using with your version of Xenix.
| Some versions of this compiler do not properly perform pointer
| arithmetic with zero, unless it is cast to a pointer type.
	The effect of pointer-int is well defined, which is what I
assume you mean. NULL is treated as an address, which will cause strange
side effects if you think it's an int (and also if you think that a zero
should be treated as an address).

	Your assumption that NULL was zero in K&R C (1st ed) is correct,
and 2nd ed. could be read to say that, although their explanation (pg
102) states assignment and comparison with pointers. In the assumption
that NULL is incorrect if defined as a pointer, you are obviously in
conflict with the ANSI standard.

	In my opinion any code which assumed the type of NULL as either
int or pointer will break on some machine.
-- 
	bill davidsen		(wedu at ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list