Xref: utzoo comp.lang.fortran:2022 comp.lang.c:18484 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!mcnc!rti!xyzzy!bert!throopw From: throopw@bert.dg.com (Wayne A. Throop) Newsgroups: comp.lang.fortran,comp.lang.c Subject: Function prototypes Message-ID: <5778@xyzzy.UUCP> Date: 8 May 89 02:21:12 GMT References: <2846@tank.uchicago.edu> <5785@cbnews.ATT.COM> <10087@smoke.BRL.MIL> <2692@tekcae.CAX.TEK.COM> <307@cbnewsh.ATT.COM> <1399@uw-entropy.ms.washington.edu> <8145@pucc.Princeton.EDU> <12942@paris.ics.uci.edu> Sender: usenet@xyzzy.UUCP Lines: 50 > schmidt@zola.ics.uci.edu (Doug Schmidt) > I'd like to know whether anyone has devised a > useful set of preprocessor conventions that allow relatively > transparent conversion between compilers that accept prototypes and > those that don't. There are many tradeoffs to be made. What I finally ended up using for situations where non-ansi compilers had to be accomodated has some drawbacks in that it requires some redundancy and prevents accurate typechecking of some of it. But it doesn't look too terribly awful, and it allows declaration of routines and contracts. It involves three macros, P, PT, and PP. The first is used in declaring functions. Where one might declare int foo( short bar, long bletch ) { ... } one would write int foo P(( bar, bletch ), short bar PP long bletch ) { ... } And in place of int (*foo)( short, long ); one would write int (*foo) PT(( short, long )); The definitions of the macros is left as an excersize to the reader. It isn't too difficult, basically setting the appropriate separators for PP, deciding whether to expand the argument to PT, and finally deciding whether to expand the first argument to P and what punctuation to put around the second one. -- If it could be demonstrated that any complex organ existed which coult not possibly have been formed by numerous, successive, slight modifications, my theory would absolutely break down. --- Charles Darwin -- Wayne Throop !mcnc!rti!xyzzy!throopw