Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!decwrl!bacchus.pa.dec.com!decatl!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.lang.c Subject: Re: Type of function returning function. Message-ID: <1843@tkou02.enet.dec.com> Date: 11 Jul 90 04:27:35 GMT References: <1990Jul10.024205.17382@media.uucp> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 22 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 *) The obvious (void *) does not work, except by accident on some machines (and, depending on the machine, some segmentation models). (void *) only works for pointers to data. For your example below, typedef int (*TYPE)(char *); >int foo(buff) char *buff; { return atoi(buff); } >TYPE bar() { return foo; } Alternatively, int (*bar())(char *) { return foo; } I recommend the typedef. -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com This is me speaking. If you want to hear the company speak, you need DECtalk.