Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!uflorida!novavax!proxftl!bill From: bill@proxftl.UUCP (T. William Wells) Newsgroups: comp.std.c Subject: Re: function returning pointer to itself Message-ID: <494@proxftl.UUCP> Date: 19 Jul 88 10:03:05 GMT References: <7725@watdragon.waterloo.edu) <664@goofy.megatest.UUCP) <7797@watdragon.waterloo.edu) <259@chem.ucsd.EDU> Reply-To: bill@proxftl.UUCP (T. William Wells) Organization: Proximity Technology, Ft. Lauderdale Lines: 31 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <259@chem.ucsd.EDU> tps@chem.ucsd.edu (Tom Stockfisch) writes: > Wrong. (void *) is guaranteed to hold any _data_ pointer. I believe you > were correct the first time, as I think (void *(*)()) is guaranteed to > hold any function pointer. (Anyone care to correct me?) 1.6 "Object -- a region of data storage in the execution environment, the contents of which can represent values". 3.1.2.5 "... and incomplete types (types that describe objects but lack..." 3.2.2.2 "A pointer to void may be converted to a pointer to any incomplete or object type. A pointer to any incomplete or object type may be converted to a pointer to void and back again; the result shall compare equal to the original pointer." However, should you need a generic function pointer: 3.3.4 "A pointer to a function of one type may be converted to a pointer to a function of another type and back again; the result shall compare equal to the original pointer. If a converted pointer is used to call a function that has a type that is not compatible with the type of the called function, the behavior is undefined." So, any function pointer type whatsoever can be used as a generic function pointer. Just so you cast it back to the original function type before doing a call with it.