Newsgroups: comp.std.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: legality of assignment of function to a void *. Message-ID: <1990Nov19.164045.11136@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1990Nov12.211511.2344@batcomputer.tn.cornell.edu> <1990Nov13.174920.2235@zoo.toronto.edu> <1990Nov14.031125.14027@athena.mit.edu> <4e0cac89.20b6d@apollo.HP.COM> <520@taumet.com> Date: Mon, 19 Nov 90 16:40:45 GMT In article tt@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@zoo.toronto.edu utzoo!henry