Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!batcomputer!llenroc!cornell!uw-beaver!mit-eddie!eddie!aryeh From: aryeh@eddie.mit.edu (Aryeh M. Weiss) Newsgroups: comp.unix.programmer Subject: Re: Recasting to a pointer to a function. Keywords: C, casts, pointer to function Message-ID: <1991Mar16.150554.25269@eddie.mit.edu> Date: 16 Mar 91 15:05:54 GMT References: <1991Mar14.155825.31@edwards-saftd-2.af.mil> Sender: news@eddie.mit.edu (Usenet News) Followup-To: comp.lang.c Organization: MIT EE/CS Computer Facilities, Cambridge, MA Lines: 14 In article <1991Mar14.155825.31@edwards-saftd-2.af.mil> elston@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;