Addresses of static functions
Kevin Martin
kpmartin at watmath.UUCP
Sat Feb 9 06:06:41 AEST 1985
In article <360 at ecr.UUCP> peterc at ecr.UUCP (Peter Curran) writes:
>The original question was, "Is it OK to take the address of a >>static<<
>function, and pass it to a separately-compiled function?"
>
>Saying the answer is "no" appears to allow the compiler to take advantage of
>the fact to optimize the calling sequence...
>
>Saying the answer is "yes" means that I don't have to declare the comparison
>function used deep inside an implementation of an abstract data type to be
>external, even though its only use is to pass its address to "qsort", and it
>shouldn't be visible to any of the users of the data type.
Seems to me the correct answer is 'yes'. Any time you take the address of
*any* function, you need to ensure that the function accepts the 'long'
calling sequence, and that you generate a pointer that is usable anywhere.
This doesn't stop you from generating a function with *both* a fast and slow
entry (if your architecture and stack design allow it), and using the slow entry
for generating the pointers for (possibly) external calls, but calling the
quick entry entry when you call the function directly.
Kevin Martin, UofW Software Development Group
More information about the Comp.lang.c
mailing list