selectively enabling prototypes

Steve Friedl friedl at mtndew.Tustin.CA.US
Mon Aug 13 02:13:57 AEST 1990


Hi folks,

     I like to use function prototypes when possible, so in my
header files I do something like this:

	#ifdef	USE_PROTO
	#  define	PROTO(name, args)	name args
	#else
	#  define	PROTO(name, args)	name ( )
	#endif

	extern PROTO(int printf, ( const char *, ... ) );
	extern PROTO(char *strcpy, ( char *, const char * ) );

and so on (note: I know that printf and strcpy are in other
headers, I'm just using familiar examples).  I have been doing
this for about two years and have been really happy with it.
However, I have seen it done "the hard way":

	#ifdef	USE_PROTO
	  extern int printf(const char *, ... );
	  extern char *strcpy(char *, const char * );
	#else
	  extern int printf()
	  extern char *strcpy();
	#endif

This looks like a real maintenance nightmare, but some of the
people who do it are people I respect, so I gotta wonder if they
know something that I don't know on this one.  Are there any
gotchas on doing it with the flavor of the way I've done it?

Note: I do know that things like signal() won't fit into my mold,
but these are so much in the minority that I don't mind doing those
few "the hard way".

     Steve

-- 
Stephen J. Friedl, KA8CMY / Software Consultant / Tustin, CA / 3B2-kind-of-guy
+1 714 544 6561  / friedl at mtndew.Tustin.CA.US  / {uunet,attmail}!mtndew!friedl

If Larry Ellison says it, it must be true.



More information about the Comp.lang.c mailing list