Xref: utzoo comp.lang.c:35151 comp.std.c:4111 Newsgroups: comp.lang.c,comp.std.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: (void *) to function pointer Message-ID: <1991Jan11.174923.7250@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1991Jan9.000809.9152@brolga.cc.uq.oz.au> <1037@mwtech.UUCP> Date: Fri, 11 Jan 1991 17:49:23 GMT In article <1037@mwtech.UUCP> martin@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@zoo.toronto.edu utzoo!henry