Newsgroups: comp.lang.c Path: utzoo!utgpu!jarvis.csri.toronto.edu!ephemeral.ai.toronto.edu!bradb From: bradb@ai.toronto.edu (Brad Brown) Subject: Re: Mutually recursive functions in C Message-ID: <89Feb12.132111est.10867@ephemeral.ai.toronto.edu> Summary: Sure, you can do anything... Organization: Department of Computer Science, University of Toronto References: <34823@tut.cis.ohio-state.edu> Date: Sun, 12 Feb 89 13:21:04 EST In article <34823@tut.cis.ohio-state.edu> william@cis.ohio-state.edu (James H. Williamson) writes: > > Does C allow mutually recursive functions & if so > what are the declaration mechanisms & could somebody > give an example? > >Jim Williamson Sure, C will let you do anything... :-) Try the following, with appropriate adjustments for your argument types: >------------------------------------- : : int func1( int argument ) { /* Remember to have a forward reference for the second function */ /* You might have to modify the syntax of this -- my compiler */ /* accepts it, but a minimal declaration is just "int func2()" */ /* with no extern -- it works but does not give you protection */ /* against type mismatches in the argument to func2(). */ extern int func2( int ); /* Do stuff */ : : func2( stuff ); : : } int func2( int argument ) { /* Don't need a forward reference for func1 here */ /* Do stuff */ : : func1( stuff ); : : } >------------------------------------- That's it! (-: Brad Brown :-) bradb@ai.toronto.edu