Curious about function prototypes...

Chris Torek chris at mimsy.UUCP
Tue Jun 14 13:42:30 AEST 1988


In article <273 at spsspyr.UUCP> gunars at spsspyr.UUCP (Gunars V. Lucans) writes:
>... For declarations, the following would suffice (from T.Plum's ...
>[magic PARMS macro]
>	void foo PARMS( (int arg1, char *arg2) );

I use something like this already (although I used

/*
 * A rather ugly way to hide prototypes from the old compiler.
 */
#ifndef _PROTO_
#if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
#define _PROTO_(x) x
#else
#define _PROTO_(x) ()
#endif
#endif

int	isalpha _PROTO_((int _c));

etc.).

>Definitions are another matter.

Indeed.

>Is there an alternative (other than not using prototypes at all) to:
>
>	void foo (
>	#ifdef PROTO_OK
>		      int
>	#endif
>	          arg1,
>	#ifdef PROTO_OK
>		      char *
>	#endif
>	          arg2)
>	{
>		<body>
>	}

This is missing one section:

	#ifndef PROTO_OK
		int arg1;
		char *arg2;
	#endif

I think I prefer

	#ifdef PROTO_OK
	void foo(int arg1, char *arg2)
	#else
	void
	foo(arg1, arg2)
		int arg1;
		char *arg2;
	#endif
	{

even if it does name everything twice (or three times!).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list