
Declaring static function returning pointer to extern function
Hi Matt,
Quote:
> I want to declare a function that has static linkage and returns a
> pointer to a function with extern linkage. Do the following
Your given example will work fine.
Directives affecting the scope of a function (or any other symbol, for that
matter) only come into play in statements that access the function by name
(e.g. pFcn = printf;). The compiler has no way of storing such directives in
a pointer to said function, and will make no effort to determine them if the
function is accessed through said function pointer. Thus, a function that
returns a pointer to a function with static linkage can not expect the
compiler to enforce said static linkage. In fact it should expect otherwise:
that the referenced function should be callable by anyone who happens to
have the address of it.
------------
Timothy J. Smith
Member, Technical Staff
Broadband Storage Inc.
(949) 737-2743
------------