Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!claris!hearn From: hearn@claris.com (Bob Hearn) Newsgroups: comp.lang.c Subject: Re: Typecast of Pointers to Functions Message-ID: <9248@claris.com> Date: 28 Mar 89 23:37:39 GMT References: <7689@killer.Dallas.TX.US> Distribution: usa Organization: Claris Corporation, Mountain View CA Lines: 25 From article <7689@killer.Dallas.TX.US>, by brian@killer.Dallas.TX.US (Brian Pellerin): > I am looking for an equivalent way to specify a typecast of a pointer to > a function other than using typedef. For Example: > > typedef int (*FCN_PTR) (); > FCN_PTR fcn_ptr1; > int (*fcn_ptr2) (); > > fcn_ptr1 = (FCN_PTR) NULL; /* Typecast using typedef */ > fcn_ptr2 = (???????) NULL; /* Do Not Use the typedef. What Goes Here? */ > > Any Suggestions? Thanks. What you want is: fcn_ptr2 = (int (*)()) NULL; The parens around the * are significant! There is a simple way to to this for any type: write a declaration, remove the identifier, and enclose it in parens. Thus: int (*FCN_PTR)() --> int (*)() --> (int (*)()) Bob Hearn hearn@claris.com