Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site gitpyr.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!gatech!gitpyr!robert From: robert@gitpyr.UUCP (Robert Viduya) Newsgroups: net.lang.c Subject: Re: declaring routines which return function pointers Message-ID: <423@gitpyr.UUCP> Date: Fri, 14-Dec-84 04:59:41 EST Article-I.D.: gitpyr.423 Posted: Fri Dec 14 04:59:41 1984 Date-Received: Sun, 16-Dec-84 06:12:53 EST References: <249@alberta.UUCP> Distribution: net Organization: Georgia Tech, Atlanta Lines: 44 > 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. I only see one way of doing it and C apparently doesn't support it. That way is to declare fa() as: int ((*fa)())(); This is broken down from: int (*x)(); /* x is a pointer to a function returning an int */ int ((*y)())(); /* y is function returning a ptr to a func returning an int */ However, both lint and cc complain with 'function returns illegal type'. May I suggest using casts? robert -- Robert Viduya Office of Computing Services Georgia Institute of Technology, Atlanta GA 30332 Phone: (404) 894-4669 ...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert ...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert