From: John Kugelman Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: Casting void pointers Date: Mon, 22 Jun 1998 01:31:01 -0400 Organization: Verio Mid-Atlantic Lines: 26 Message-ID: <358DEC15.7441F34@mnsinc.com> References: <6mkaos$k7o AT dfw-ixnews6 DOT ix DOT netcom DOT com> <358DE928 DOT 2F8C4608 AT mnsinc DOT com> NNTP-Posting-Host: kugelman.mnsinc.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I wrote: > > double foo (double d) > { return d * 2.0; } > > int main (void) > { > /* Store function pointer in "generic" pointer. */ > void (*func) (void) = foo; > > /* Cast pointer back to original type before calling it. */ > printf ("%f\n", ((double (*) (double)) func) (5.0)); > > return 0; > } Silly me, I went and ignored my compiler's warnings (I just can't explain it). There should be an #include at the top, and foo should be cast to the appropriate type in the initialization of func. -- John Kugelman. kugelman AT mnsinc DOT com I believe we can change anything. I believe in my dream. - Joe Satriani