Xref: news2.mv.net comp.os.msdos.djgpp:2793 From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: A Proper Cast for a Funtio Date: Tue, 16 Apr 1996 06:26:51 -0700 Organization: Alcyone Systems Lines: 35 Message-ID: <3173A01B.54FD7FF8@alcyone.com> References: <199604120528 DOT BAA00833 AT mail-e2b-service DOT gnn DOT com> NNTP-Posting-Host: newton.alcyone.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 Jethro Wright wrote: > Wang: Good point, as I overlooked that possibility. Truth is, > I don't really use fn ptr coercion all that much, but decided to ask > this time, since I've had a couple of occasions to use such a thing in > that past couple of months and this was as good a time as any to learn > about this bit of C obscurity.... Jet You should, but this isn't a case of obscurity, it's a case of implementation-dependence. Casting function pointers is implicitly implementation dependent and the results of executing a casted function are undefined. If you find yourself needing to cast function pointers, it means that you're doing something nonportable or just plain wrong. But if you need to, the type of a function pointer, like all other types in C, looks like a declaration with the identifier stripped away. That is, if int (*function)(int x); is a valid declaration of a function pointer function which takes an int argument and returns an int, then the type of this function pointer can be written int (*)(int x) Casting a value to this type would look like (int (*)(int x)) value -- Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max AT alcyone DOT com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_