Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!lll-crg!ames!cit-vax!oddhack!jon
From: jon@oddhack.Caltech.Edu (Jon Leech)
Newsgroups: comp.lang.c++
Subject: Function prototypes in C and C++
Message-ID: <1328@cit-vax.Caltech.Edu>
Date: Thu, 11-Dec-86 22:37:02 EST
Article-I.D.: cit-vax.1328
Posted: Thu Dec 11 22:37:02 1986
Date-Received: Sun, 14-Dec-86 04:41:13 EST
Sender: news@cit-vax.Caltech.Edu
Reply-To: jon@cit-vax.UUCP (Jon Leech)
Organization: California Institute of Technology
Lines: 24


	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
    __@/