[comp.lang.c++] Function prototypes in C and C++

jon@oddhack.Caltech.Edu (Jon Leech) (12/12/86)

	I have been writing a fair amount of code recently which mixes
C and C++ (unavoidably). I find the following little trick useful in
making header files which both C and C++ are happy with:

	#ifdef c_plusplus
	#define DECL(func,args) func() ;
	#else
	#define DECL(func,args) func args ;
	#endif

and then declare functions like this:

	DECL(extern char *malloc,(int))
	DECL(extern my_type myfunc,(other_type *, double, int))

whenever ANSI C comes into existence, the conditional definition of DECL
can just be removed. The usage is a little ugly but does the job. I forget
who created the macro originally; there was some discussion on prototypes
in mod.std.c many moons ago that led to this.

    -- Jon Leech (jon@csvax.caltech.edu || ...seismo!cit-vax!jon)
    Caltech Computer Science Graphics Group
    __@/