Typecast of Pointers to Functions
John Mundt
john at chinet.chi.il.us
Thu Mar 30 01:30:00 AEST 1989
In article <7689 at killer.Dallas.TX.US> brian at killer.DALLAS.TX.US (Brian Pellerin) writes:
>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? */
What you need is the following cast
fcn_ptr2 = (int (*)()) NULL;
If you look at your typedef, you'll see that this is virtually the same thing
with the name taken out and with the casting parentheses put around the
entire thing.
Why not use 0 instead of NULL, too?
--
---------------------
John Mundt Teachers' Aide, Inc. P.O. Box 1666 Highland Park, IL
john at chinet.chi.il.us
(312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem
More information about the Comp.lang.c
mailing list