Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Declaring static function returning pointer to extern function (http://www.velocityreviews.com/forums/t868804-declaring-static-function-returning-pointer-to-extern-function.html)

pembed2012 02-27-2012 07:55 PM

Declaring static function returning pointer to extern function
 
I want to declare a function that has static linkage and returns a
pointer to a function with extern linkage. Do the following
declarations acheive that, or do they declare a function that returns
a pointer to a function with static linkage?

typedef void Foo(void);
static Foo * Bar(void){
//Bar

}

James Kuyper 02-27-2012 08:21 PM

Re: Declaring static function returning pointer to extern function
 
On 02/27/2012 02:55 PM, pembed2012 wrote:
> I want to declare a function that has static linkage and returns a
> pointer to a function with extern linkage. Do the following
> declarations acheive that, or do they declare a function that returns
> a pointer to a function with static linkage?
>
> typedef void Foo(void);
> static Foo * Bar(void){
> //Bar
>
> }


There's no such thing as a distinction, in terms of type, between
pointers to functions base upon whether the pointed-at function has
internal linkage or external linkage. Linkage applies only to specific
function or object identifiers. That declaration makes Bar itself a
function with internal linkage, but allows it to return a pointer that
could equally easily point to a function with internal or external linkage.


All times are GMT. The time now is 11:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.