Declaring static function returning pointer to extern function

P

pembed2012

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

}
 
J

James Kuyper

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top