Mutually recursive functions in C

Karl Heuer karl at haddock.ima.isc.com
Tue Feb 14 05:58:44 AEST 1989


In article <447 at thirdi.UUCP> peter at thirdi.UUCP (Peter Rowell) writes:
>william at cis.ohio-state.edu (James H. Williamson) writes:
>>Does C allow mutually recursive functions...
>
>[Yes.]  If the routines return anything other than "int" (or if you are using
>ANSI C with prototypes), you will need to place an extern declaration in the
>front of the file so that the compiler doesn't bitch about "Redeclaration of
>procedure Foo"...

Or, if the routines are intended to be local, then you should forward-declare
them using `static' (and hope your compiler isn't one of the broken ones that
can't handle this):
	static ftype_t f();
	static gtype_t g();
	...
	static ftype_t f() { ... g(); ... }
	static gtype_t g() { ... f(); ... }

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list