Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Function returning pointer to function ? (80 lines) Message-ID: <917@umcp-cs.UUCP> Date: Fri, 19-Jul-85 22:02:43 EDT Article-I.D.: umcp-cs.917 Posted: Fri Jul 19 22:02:43 1985 Date-Received: Sun, 21-Jul-85 02:38:48 EDT References: <11582@brl-tgr.UUCP> <635@kvvax4.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 25 Once again, ``cdecl'' to the rescue: > /* Now my turn to ask a question. Here are the declarations: */ > char *f1() { return("1"); } > char *f2() { return("2"); } > /* decl array of ptrs to fns returning ptr to char */ > char *(*funcs[2])() = {f1,f2}; > /* decl ptr to array of ptrs to fns returning ptr to char */ > char *(*(*pfuncs)[])() = funcs; > /* "junk.c", line 47: warning: illegal pointer combination */ > /* I can't get that to compile without a warning but it works ok. */ % cdecl << eof declare pfuncs as pointer to array of pointer to function returning pointer to char eof Warning: Unsupported in C -- Pointer to array of unspecified dimension char *(*(*pfuncs)[])() % It not only gives you the required declaration, it even tells you why the compiler won't like it! :-) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland