Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 1997 13:12:11 -0500
From:      Joel Ray Holveck <joelh@gnu.ai.mit.edu>
To:        eivind@dimaga.com
Cc:        wollman@lcs.mit.edu, chat@freebsd.org
Subject:   Re: cvs commit: CVSROOT avail
Message-ID:  <199702091812.NAA27046@kropotkin.gnu.ai.mit.edu>
In-Reply-To: <3.0.32.19970206180051.00abec10@dimaga.com> (message from Eivind Eklund on Thu, 06 Feb 1997 18:00:52 %2B0100)

next in thread | previous in thread | raw e-mail | index | archive | help
 > Anyway; I would not recommend using ANSI prototypes and K&R style
 > definitions - 
 > this can create some weird parameter conversions which are unlikely to give
 > much problems on a machine with pure 32-bit parameter passing, but can
 > potentially give weird problems on later ports.

If my understanding is correct, having an ANSI prototype and a K&R
definition is the same as having an ANSI prototype and an ANSI
definition, or an ANSI definition before any calls, as far as calls
within the same object file go.  (For calls outside the same object
file, there can be some differences between the promotions used for
prototypeless calls and prototyped calls, but that's a different
issue.)

Is this incorrect?

 >> 5) Never use NULL.  Write it `0', and provide casts as appropriate.
 > This is makes it more difficult to see, and provide less typechecking.
 > Casts must be provided as appropriate, of course.

I have to agree with you here.  Using NULL makes it clear that you are
referring to a pointer.  It's kind of like using `null' or `not' in
Lisp.

Moreover, assuming the OS vendor (I know we're mainly talking FreeBSD
here, but no reason not to encourage portable code writing) has
properly #defined NULL as ((void*)0) on compilers which grok the void*
type, and ((char*)0) on the others, then it will be properly handled
in a prototypeless call without a cast on machines where
sizeof(int) != sizeof(void*).  (If I recall correctly, pointer types
*never* have default promotions, so machines which have different
pointer formats for different types will still die, but that's another
issue.)

 >> 11) Don't use in lint(1) ``control comments''.  Nobody uses lint.
 > I've just turned into "nobody". :)

Although lint was handy in earlier days, I find that most compilers'
warnings are better now.  I typically use `gcc -Wall -W
-Wbad-function-cast -Wcast-align -Wcast-qual -Wconversion
-Wpointer-arith -Wshadow -Wwrite-strings' in my code during
development, and it helps me catch more bonehead mistakes than lint
ever did.

If you use lint, I have no problems seeing control comments now and
again.  But, to quote rms, "Don't make your code ugly to placate
lint."

Happy hacking,
joelh

-- 
http://www.wp.com/piquan --- Joel Ray Holveck --- joelh@gnu.ai.mit.edu
All my opinions are my own, not the FSF's, my employer's, or my dog's.

Second law of programming:
Anything that can go wrong wi
sendmail: segmentation violation -- core dumped



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702091812.NAA27046>