Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!grebyn!ckp From: ckp@grebyn.com (Checkpoint Technologies) Newsgroups: comp.lang.c Subject: Re: Type of function returning function. Message-ID: <20299@grebyn.com> Date: 13 Jul 90 07:25:18 GMT References: <1990Jul10.024205.17382@media.uucp> Reply-To: ckp@grebyn.UUCP (Checkpoint Technologies) Organization: Grebyn Timesharing, Vienna, VA, USA Lines: 56 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? ^^^^^^^^ To start with, function-ness is not a "terminating" data type. What you really mean to say is I want a TYPE representing a pointer to a function returning an *int* (as in your example). >Example: > >int foo(buff) >char *buff; >{ > return atoi(buff); >} > >TYPE bar() >{ > return foo; >} You could think about it this way: typedef int (*TYPE)(); /* TYPE is a pointer to a function returning int */ or, with prototypes for the above example: typedef int (*TYPE)(char *buff); This typedef would make the above example work (I think). Without the typedef, bar() would be defined as: int (*)() bar() /* well, this DOES look weird... */ { ... } er, or maybe... int (*) (bar()) () /* nah, I think the first one is right... */ { ... } >I would have thought that it would be something like >int ((*)()), but gcc doesn't agree. Help... Well, try the second one above. >Roger Fujii - Media Cybernetics Phone: (301)495-3305 >Internet: rmf%media@uunet.uu.net UUCP: {uunet,hqda-ai}!media!rmf Chris -- First comes the logo: C H E C K P O I N T T E C H N O L O G I E S / / \\ / / Then, the disclaimer: All expressed opinions are, indeed, opinions. \ / o Now for the witty part: I'm pink, therefore, I'm spam! \/