Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!charyb!will From: will@kfw.COM (Will Crowder) Newsgroups: comp.lang.c Subject: Re: Type of function returning function. Keywords: pain in butt Message-ID: <1990Jul11.155451.13457@kfw.COM> Date: 11 Jul 90 15:54:51 GMT References: <1990Jul10.024205.17382@media.uucp> Reply-To: will@kfw.com (Will Crowder) Followup-To: comp.lang.c Distribution: na Organization: KFW Corporation, Newbury Park, CA Lines: 52 In article <1990Jul10.024205.17382@media.uucp> rmf@media.uucp (Roger Fujii) writes: >So, just how does one type a function returning a pointer to a function? >(other than the obvious void *) > >Example: > >int foo(buff) >char *buff; >{ > return atoi(buff); >} > >TYPE bar() >{ > return foo; >} > >I would have thought that it would be something like >int ((*)()), but gcc doesn't agree. Help... > >-- >Roger Fujii - Media Cybernetics Phone: (301)495-3305 >Internet: rmf%media@uunet.uu.net UUCP: {uunet,hqda-ai}!media!rmf These are a pain. int (*bar())(); ought to do it for you though. I'm sure it's been discussed here before, but there exists something called the "right-left" rule for deciphering and creating C declarations, and it comes in quite handy. If you haven't heard of it, ask your local C guru or e-mail me, and I'll be happy to explain it. OBTW, if you want a full prototype, based on what you have above, it would be: int (*bar(void))(char *); and the typedef would be: typedef int (*TYPE(void))(char *); or typedef int (*TYPE())(); without the prototypes. Hope this helps, Will