From owner-freebsd-chat Sun Feb 9 10:12:32 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id KAA26588 for chat-outgoing; Sun, 9 Feb 1997 10:12:32 -0800 (PST) Received: from albert.gnu.ai.mit.edu (albert.gnu.ai.mit.edu [128.52.46.31]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id KAA26583 for ; Sun, 9 Feb 1997 10:12:22 -0800 (PST) Received: from kropotkin.gnu.ai.mit.edu by albert.gnu.ai.mit.edu (8.6.12/8.6.12GNU) with ESMTP id NAA09807; Sun, 9 Feb 1997 13:14:14 -0500 Received: by kropotkin.gnu.ai.mit.edu (8.6.12/4.0) id ; Sun, 9 Feb 1997 13:12:11 -0500 Date: Sun, 9 Feb 1997 13:12:11 -0500 Message-Id: <199702091812.NAA27046@kropotkin.gnu.ai.mit.edu> To: eivind@dimaga.com CC: wollman@lcs.mit.edu, chat@freebsd.org In-reply-to: <3.0.32.19970206180051.00abec10@dimaga.com> (message from Eivind Eklund on Thu, 06 Feb 1997 18:00:52 +0100) Subject: Re: cvs commit: CVSROOT avail From: Joel Ray Holveck Reply-to: joelh@gnu.ai.mit.edu Sender: owner-chat@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > 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