From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from most.weird.com ([204.92.254.2]) by hawkwind.utcs.utoronto.ca with SMTP id <24634>; Wed, 26 Mar 1997 14:54:17 -0500 Received: by most.weird.com via sendmail with stdio id for rc@hawkwind.utcs.toronto.edu; Wed, 26 Mar 1997 11:38:37 -0500 (EST) (Smail-3.2.0.93-pre 1997-Mar-5 #11 built 1997-Mar-5) Message-Id: Date: Wed, 26 Mar 1997 11:38:37 -0500 From: woods@most.weird.com (Greg A. Woods) To: rc@hawkwind.utcs.toronto.edu Subject: Re: RC => POSIX In-Reply-To: Bengt Kleberg's message of "Wed, March 26, 1997 09:33:04 +0100" regarding "Re: RC => POSIX" id <199703260833.JAA02345@uabx04c397.uab.ericsson.se> References: <199703260833.JAA02345@uabx04c397.uab.ericsson.se> Reply-To: woods@weird.com (Greg A. Woods) X-Mailer: ViewMail (vm) Version 5.96 (beta) with GNU Emacs 19.34.1 (m68k.68881-sun-sunos4.1.1, X toolkit) of Thu Sep 12 1996 on most Organization: Planix, Inc.; Toronto, Ontario; Canada [ On Wed, March 26, 1997 at 09:33:04 (+0100), Bengt Kleberg wrote: ] > Subject: Re: RC => POSIX > > I interpreted Mr Rakitzis previous message as a suggestion that ANSI > function prototypes should go, since K&R C is more portable (available > on more systems). The problem is that while prototypes help catch parameter mismatches, they must be used with strict new-style function definition syntax, esp. with some less lax ANSI compilers (this is due to incompatabilities invoving type promotion in expressions between ANSI C and K&R C). As a result the code gets very messy if you try to #ifdef both styles. Indeed pure K&R C is still far more portable, and with careful use of lint, still safer (in the sense that more function call problems can be prevented) than most ANSI compilers are today. Where I'm getting at here is that the most portable style of C coding is probably to use ANSI definitions and prototypes exclusively, and rely on some tool such as unproto or ansi2knr to automatically support older compilers. BTW, I've had far better luck with unproto, and it doesn't require any makefile magic if it's installed properly on the target system, though ansi2knr (from the GNU automake distribution) is easier to use since you ship it with the package and automake does all the "right" things to build portable makefiles for using it. This of course necessitates still running lint occasionally with k&r type promotion checking turned on and inserting all casts necessary for k&r in function calls. This is probably what would be best for rc since most of the developers are likely to use ANSI C compilers and thus can benefit immeadiately from prototype checking even if they don't have a working lint implementation in their enironments. Personally I detest ANSI function definition syntax (it is difficult to read and very inelegant), and so I stick to straight k&r C in my own code and rely on lint for more complex syntax checking. Prototypes can even work if you're using an ANSI compiler that can be told to always follow k&r type promotion (eg. GCC). -- Greg A. Woods +1 416 443-1734 VE3TCP robohack!woods Planix, Inc. ; Secrets of the Weird