Xref: utzoo comp.lang.c:26665 comp.std.c:2560 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!dinorah.wustl.edu!art From: art@dinorah.wustl.edu (Arthur B. Smith) Newsgroups: comp.lang.c,comp.std.c Subject: How do I define function returning pointer to function returning int? Keywords: function returning function pointer, ANSI C, Message-ID: <1990Mar7.212639.10313@dinorah.wustl.edu> Date: 7 Mar 90 21:26:39 GMT Followup-To: comp.std.c Organization: Computerized Medical Systems Lines: 53 HELP!! My "ANSI C" references (K&R2 and Mark Williams' "ANSI C, A Lexical Guide") are conflicting and vague on an important (to me) issue, and I don't have a copy of the standard (draft or otherwise). I think the pertinent section of the standard may be 3.7.1 The simplest question is "Can you define a function of no arguments that returns a pointer to a function returning int?" The next question is "How?" Several contenders I see are: #1) int (* gorp ()) ( void ) {...} #2) int ((* gorp)()) ( void ) {...} #3) typedef int (* gorp_t)(); gorp_t gorp ( int a, int b ) {...} #4) typedef int ((* gorp_t)()); gorp_t gorp ( int a, int b ) {...} Which of these are legal? Why are those that are not legal illegal? Which of these can I reasonably expect a compiler to support? What about "old style" C? BTW, I am assuming that it is perfectly legal to pass parameters that are pointers to functions returning int, e.g., int frzp ( int (* farg)() ) {...} or int frzp2 ( int ((* farg)()) ) {...} if I am wrong here, please let me know! (And again, what about "old style" C?) I am -art smith (art@dinorah.wustl.edu or ...!uunet!wucs1!dinorah!art)