Automatic converters (K&R C => ANSI C) (K&R C => C++) (ANSI C => K&R C)

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Tue Oct 31 02:06:01 AEST 1989


In article <1989Oct27.190150.22043 at paris.ics.uci.edu>, rfg at ics.uci.edu (Ron Guilmette) writes:
|  >and produces:
|  >
|  >     #ifdef ANSIPROTO
|  >      int xyz(char *c, FILE *f);
|  >     #else
|  >      int xyz();
|  >     #endif

  I might suggest that this could make for large and possibly hard to
read code, and that it have the declarations in two places, with the
possibility that future editing will add/delete/change only one.

  I offer the following suggestion which some people may find useful.
Define a macro:

	#ifdef	ANSIPROTO
	#define PARAM(x)	x
	else	/* old style */
	#define PARAM(x)	()
	#endif	/* meaning of PARAM */

Then you can say (note two levels of parens):
	extern lsf PARAM((int, int, int*));

  This results in only one line for the prototype, and is still pretty
readable. You can include names or just types as you please.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.std.c mailing list