ANSI/K&R functions in same source
doel at kirkwood.crd.ge.com
doel at kirkwood.crd.ge.com
Tue Jan 22 01:33:41 AEST 1991
Hi,
I imagine this type of thing has been discussed before, so I apologize
for any repitition. I write most of my code on a PC using an ANSI
compiler. One of the biggest plusses of ANSI is of course, the function
prototypes. However, I also like to use some of the tools available (e.g.
lint) on Unix boxes that don't know about prototypes (when will this
change?). I have been writing code in the following manner:
in my_decl.h
-------------
#ifdef __STDC__
void func1(int arg1, double arg2);
char *func2(char *arg3);
#else
void func1();
char *func2();
#endif
in my_code.c
------------
#ifdef __STDC__
void func1(int arg1, double arg2)
#else
void func1(arg1,arg2)
int arg1;
double arg2;
#endif
etc...
While this works (i.e. I don't have to run some ansi-to-k&r filter or vice
versa), I imagine that there is a more elegant solution. Is there a clean
way to write functions which can be compiled immedaitely on ANSI & KR
compilers while retaining function prototypes on the ANSI compilers?
Thanks in advance
Mike
More information about the Comp.lang.c
mailing list