home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!usc!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!lyra.scs.uiuc.edu!mcdonald
- From: mcdonald@aries.scs.uiuc.edu (J. D. McDonald)
- Subject: Re: Is that ansi ?
- References: <1992Dec30.203127.25625@jpradley.jpr.com> <725809262snz@rcsl.demon.co.uk> <1993Jan8.142730.20697@osf.org>
- Message-ID: <mcdonald.28@aries.scs.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: UIUC SCS
- Date: Fri, 8 Jan 1993 15:02:20 GMT
- Lines: 24
-
- In article <1993Jan8.142730.20697@osf.org> daniel@moonshine.osf.org (Daniel Dardailler) writes:
-
- >A compiler is reporting the following warning:
-
- > "void * and function pointers are not convertible to each other"
-
- >when encountering:
-
- > void * p = (void *) func ; /* func of any kind */
-
-
- I'm afraid it's true, and one of the most serious faults of ANSI C.
-
- Function pointers are orthogonal to everything else. What you can do
- is somehow convert them to an integer type and convert that to
- void * pointer and then go back. The standard itself does not
- guarantee that the conversion will get back the right answer however.
- (For those who need a proof, checked with Doug Gwyn, that this can be done:
- enclose the function pointer in a struct, write out the struct to a
- file using fwrite, then read back in into a char array of the correct size.
- This is guaranteed to work.) Another way is to try and use unions. This
- is not absolutely guaranteed to work.
-
- Doug McDonald
-