Recasting to a pointer to a function.

elston at edwards-saftd-2.af.mil elston at edwards-saftd-2.af.mil
Fri Mar 15 09:58:25 AEST 1991


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


   int (*dbp)();
   long lvar;
   .
   .
   .
   dbp = (()*) lvar;

and it failed to compile.  Is there any method for doing this recast?  The
other option we have tried is

   (long) dbp = lvar;

but when we run this we get a core dump (at the minimum).  We are not sure if
this is due to improper handling of the recast (should not be) or ?????
Does anyone have any ideas?

Thanks in advance,

Mark
-- 
##############################################################################
# A mind is a terrible thing to waste -      elston at edwards-saftd-2.af.mil   #
#     Thank goodness mine's all used up.                                     #
#                                                                            #
# If the author has expressed any opinions here they are purely              #
#  accidental and should be ignored.                                         #
##############################################################################



More information about the Comp.unix.programmer mailing list