(void *) to function pointer
Henry Spencer
henry at zoo.toronto.edu
Sat Jan 12 04:49:23 AEST 1991
In article <1037 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
>A less portable solution to transfer a function pointer to a `void *'
>is an intermediate cast to an `int'. The ANSI standard allows such
>casts...
Yes and no. The wording of the standard implies, but does not quite
state explicitly, that there is *some size* of integer that is big enough
to hold a pointer. There is no promise that `int' suffices; it might
have to be `long', or even some nonstandardness like `long long'.
Note also that the standard does not promise that you can convert a
pointer to an integer (one that is big enough to hold it) and back
and get a useful pointer. The description of pointer-integer conversions
is full of "implementation-defined" and "undefined" and makes very few
promises.
--
If the Space Shuttle was the answer, | Henry Spencer at U of Toronto Zoology
what was the question? | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.std.c
mailing list