Mail Archives: djgpp/1996/04/16/22:49:49
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_
- Raw text -