Declaring static function returning pointer to extern function

Discussion in 'C Programming' started by pembed2012, Feb 27, 2012.

  1. pembed2012

    pembed2012 Guest

    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

    }
     
    pembed2012, Feb 27, 2012
    #1
    1. Advertising

  2. pembed2012

    James Kuyper Guest

    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.
     
    James Kuyper, Feb 27, 2012
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Matthews
    Replies:
    5
    Views:
    2,484
    tom_usenet
    Aug 2, 2004
  2. Brandon
    Replies:
    2
    Views:
    490
    Arne Adams
    Aug 8, 2004
  3. lou zion
    Replies:
    7
    Views:
    6,865
    Rolf Magnus
    Feb 28, 2005
  4. Replies:
    12
    Views:
    1,044
    Keith Thompson
    Sep 17, 2005
  5. Andre
    Replies:
    5
    Views:
    550
    Keith Thompson
    Jul 17, 2012
Loading...

Share This Page