Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Func Protos with K&R Func Defs Message-ID: <4865@goanna.cs.rmit.oz.au> Date: 3 Mar 91 06:31:22 GMT References: <1991Mar1.030739.9683@nlm.nih.gov> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 66 In article , jdarnold@pondsquid.mv.com (Jonathan Arnold) writes: > usenet@nlm.nih.gov (usenet news poster) writes: [about a way of coding for both ANSI and Classic C, with examples] > int tkline ARGLIST( ( bufP, tbufP, tokv, tokmax, vsepP, isepP ) ) > NFARG ( char *bufP ) /* Buffer ptr */ > NFARG ( AREG1 char *tbufP) /* Token buffer pointer */ > NFARG ( AREG2 char **tokv) /* Arg vectors */ > NFARG ( int tokmax) /* Max # tokens */ > NFARG ( char *vsepP) /* Visible separators */ > FARG ( char *isepP) /* Invisible separators */ > It is kind of ugly, but it works and you get full function prototyping. > What does everyone out there think of this method? That it is redundant when there is no need at all for redundancy. All you have to do is take your ANSI C headers, stick a few more commas in, and add an identifier: #ifdef __STDC__ #define PROTO(x) x #define A1(t1,v1) \ (t1 v1) #define A2(t1,v1,t2,v2) \ (t1 v1, t2 v2) #define A3(t1,v1,t2,v2,t3,v3) \ (t1 v1, t2 v2, t3 v3) #define A4(t1,v1,t2,v2,t3,v3,t4,v4) \ (t1 v1, t2 v2, t3 v3, t4 v4) #define A5(t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ (t1 v1, t2 v2, t3 v3, t4 v4, t5 v5) #define A6(t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ (t1 v1, t2 v2, t3 v3, t4 v4, t5 v5, t6 v6) #else #define PROTO(x) () #define A1(t1,v1) \ (v1) t1 v1; #define A2(t1,v1,t2,v2) \ (v1,v2) t1 v1; t2 v2; #define A3(t1,v1,t2,v2,t3,v3) \ (v1,v2,v3) t1 v1; t2 v2; t3 v3; #define A4(t1,v1,t2,v2,t3,v3,t4,v4) \ (v1,v2,v3,v4) t1 v1; t2 v2; t3 v3; t4 v4; #define A5(t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ (v1,v2,v3,v4,v5) t1 v1; t2 v2; t3 v3; t4 v4; t5 v5; #define A6(t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ (v1,v2,v3,v4,v5) t1 v1; t2 v2; t3 v3; t4 v4; t5 v5; t6 v6; #endif The example then becomes int tkline A6( char*, bufP, /* Buffer pointer */ AREG1 char*, tbufP, /* Token buffer pointer */ AREG2 char**,tokv, /* Arg vectors */ int, tokmax, /* Max # of tokens */ char*, vsepP, /* Visible separators */ char*, isepP) /* Invisible separators */ { ... } All done by kindness. -- The purpose of advertising is to destroy the freedom of the market.