Recasting to a pointer to a function.
Aryeh M. Weiss
aryeh at eddie.mit.edu
Sun Mar 17 01:05:54 AEST 1991
In article <1991Mar14.155825.31 at edwards-saftd-2.af.mil> elston at edwards-saftd-2.af.mil writes:
>We are trying to assign to a pointer to a function the value stored in a
>long (which on our system is the same size.) We would like to recast the long
>into a function pointer. Is there any method for doing this in 'C'?
>We tried the following
The ``proper'' way is not to do it at all, but rewrite your app into
a portable form, or to use a union like
union { long x; (int *p)(); } temp;
but you already know that.
The correct form of the cast is
dbp = (int (*)()) lvar;
More information about the Comp.unix.programmer
mailing list