Func Protos with K&R Func Defs

David E. Smyth david at jpl-devvax.JPL.NASA.GOV
Thu Feb 28 12:11:10 AEST 1991


I do this all the time:

in WcCreate.h:

    #ifdef _FUNCTION_PROTOTYPES
    ...
    extern void WcWidgetCreation ( Widget root );
    ...
    #else
    ...
    extern void WcWidgetCreation();
    ...
    #endif

in WcCreate.c:

    void WcWidgetCreation ( root )
        Widget       root;
    {
        ...
    }

This seems like the easiest way to use prototyped function declatations
when your compiler supports it, and K&R function definitions in any
case.  Then only the *.h files need to have #ifdef's.

Then "gcc -ansi -D_FUNCTION_PROTOTYPES" still does return type and
argument checking across function calls, as long as it sees the
prototyped function declaration before it is used somewhere.  And "cc"
still does little or no checking...

Does anybody have any problems with this on their compilers?

-------------------------------------------------------------------------
David Smyth				david at jpl-devvax.jpl.nasa.gov
Senior Software Engineer,		seismo!cit-vax!jpl-devvax!david
X and Object Guru.			(818)393-0983
Jet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109
------------------------------------------------------------------------- 
	One of these days I'm gonna learn:  Everytime I throw
	money at a problem to make it disappear, the only thing
	that disappears is my money...
-------------------------------------------------------------------------



More information about the Comp.lang.c mailing list