Static Function Invocation Thru Pointer

Paul Svensson pausv at sssab.se
Tue Mar 5 01:56:53 AEST 1991


henry at zoo.toronto.edu (Henry Spencer) writes:
>In article <1991Mar3.002250.26164 at agate.berkeley.edu> labc-1ia at web-3g.berkeley.edu (Andrew M. Choi) writes:
>>Hi.  This article is about the question of invoking a static
>>function in another file through the use of pointer to
>>function...
>
>That is perfectly legitimate.  If you can get a pointer to it, you can
>call it.  "static" just means that the *name* is not visible outside the
>file where it is defined.

I had some fun(?) with this when (de)porting Hack to bsd 2.9...

Henry is right, of course, but you shouldn't trust all C implementators to
know this.  CC on the pdp/11 did this wrong in one case; whe using overlays,
functions declared static did not get a "thunk" in the base overlay, and when
a pointer to a static function was passed off to someone in another overlay,
using it there had interesting results :-)

			/Paul
-- 
Paul Svensson   _   /|   - Every absurdity needs a champion to defend it -
SM5SJS          \'o.0'   Scandinavian System Support    Fax: +46 13 115193
paul at sssab.se   =(___)=  Box 535        _             Phone: +46 13 111660
sunic!sssab!paul   U     SE-581 06  Linkoping, Sweden  Home: +46 13 121021



More information about the Comp.lang.c mailing list