Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!gatech!hubcap!ncrcae!ncr-sd!hp-sdd!hplabs!sm.unisys.com!csun!solaria!ecphssrw
From: ecphssrw@solaria.csun.edu (Stephen Walton)
Newsgroups: comp.sys.amiga.tech
Subject: Prototypes (was: Re: IFF.LIBRARY)
Summary: How to use 'em in a compiler without prototypes
Message-ID: <397@solaria.csun.edu>
Date: 6 Dec 88 22:59:31 GMT
References: <62827UH2@PSUVM> <587@wuphys.UUCP> <17863@agate.BERKELEY.EDU>
Reply-To: ecphssrw@robin.csun.edu (Stephen R. Walton)
Organization: California State University, Northridge
Lines: 26


Here's a handy hint for people who need to maintain code both on
compilers with and without prototypes.  I've been meaning to post it
for a while, and Mike Meyers's posting reminded me. It comes from
Thomas Plum's excellent book _Reliable Data Structures in C_.  And no,
you Modula hackers, this title is not an oxymoron :-) . 
   The basic idea is to wrap prototype declarations in a declaration
called, for the example, PARMS.  For instance:

void *AllocMem PARMS((ULONG size, ULONG flags));

Note the double parens.  We can then do:

#if HAVE_PROTOTYPES
#define PARMS(x) x
#else
#define PARMS(x) ()
#endif

which replaces the PARMS macro with a prototype or with a set of empty
parens.  I use Manx 3.6a but also have Lint, so I use the above
convention, where HAVE_PROTOTYPES is #ifdef'd on _lint_. 
-- 
Stephen Walton, Dept. of Physics & Astronomy, Cal State Univ. Northridge
RCKG01M@CALSTATE.BITNET       ecphssrw@afws.csun.edu
swalton@solar.stanford.edu    ...!csun!afws.csun.edu!bcphssrw