legality of assignment of function to a void *.

Henry Spencer henry at zoo.toronto.edu
Tue Nov 20 03:40:45 AEST 1990


In article <TT.90Nov18144547 at tarzan.jyu.fi> tt at tarzan.jyu.fi (Tapani Tarvainen) writes:
>If I want a variable to be able to hold pointers to different
>functions, do I have to use union and list all function types I want,
>or can I assume all function pointers are similar and can (with
>suitable cast) be assigned to variables of different function pointer
>type safely? ...

The standard guarantees that you can convert one kind of function pointer
to another and back and get a pointer equal to the original (3.3.4).  So
you can use any function-pointer type to store pointers to arbitrary
functions.  However, you must convert the pointer to the correct type
for the function it points to before using it, or the result is undefined.
-- 
"I don't *want* to be normal!"         | Henry Spencer at U of Toronto Zoology
"Not to worry."                        |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.std.c mailing list