Prototypes

ark at alice.UUCP ark at alice.UUCP
Sun Mar 20 02:13:04 AEST 1988


Here is one sensible way to deal with prototypes:

Suppose you are writing a function to be used by others.
Let's call it foo().  Declare it in foo.h:

	extern double foo (int, char *, long);

When you write foo.c, be sure to include foo.h:

	#include "foo.h"

	double foo (int n, char *p, long size)
	{
		/* stuff */
	}

Indeed, you have stated foo's signature twice.
However, the compiler should reject an attempt to
compile foo.c if the two instances do not match.

Now a user who includes foo.h will automatically
get the right declaration.



More information about the Comp.lang.c mailing list