declaring routines which return function pointers

Chris Torek chris at umcp-cs.UUCP
Mon Dec 17 21:58:54 AEST 1984


> > I have a routine which resembles the following:
> > 
> > 	int (*f)();
> > 	int fa(), fb();
> > 
> > 	fa() {
> > 		f = fb;
> > 		return(f);
> > 	}
> > 
> > 	fb() {
> > 	}
> > 
> > The problem with the above is that lint complains about an illegal combin-
> > ation of a pointer with an integer in the 'return' statement.  I have tried
> > various casts and function declarations to try to satisfy lint, but none of
> > them have worked.  Does anybody know what I should do to keep lint happy?
> > 

> I played around with the code for about 30 minutes and the only thing I
> accomplished was to make lint core dump twice.

Oh good grief!  Try

	int (*f)();
	int fb();
	int (*fa())();

	int (*fa())() {
		f = fb;
		return f;
	}

	fb() {
	}
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list