function returning pointer to itself

T. William Wells bill at proxftl.UUCP
Tue Jul 19 20:03:05 AEST 1988


In article <259 at chem.ucsd.EDU> tps at 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.



More information about the Comp.std.c mailing list