§3.5/6 in the C++11 Standard

Discussion in 'C++' started by Ayrosa, Apr 29, 2014.

  1. Ayrosa

    Ayrosa Guest

    §3.5/6

    The name of a function declared in block scope and the name of a variable declared by a block scope extern declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and
    type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity isfound, the block scope entity receives external linkage.[ Example:

    static void f();
    static int i = 0; // #1
    void g() {
    extern void f(); // internal linkage
    int i; // #2 i has no linkage
    {
    extern void f(); // internal linkage
    extern int i; // #3 external linkage
    }
    }

    There are three objects named i in this program. The object with internal linkage introduced by the declaration in global scope (line #1 ), the objectwith automatic storage duration and no linkage introduced by the declaration on line #2, and the object with static storage duration and external linkage introduced by the declaration on line #3. --end example ]

    Consider the i object in line #3. Why does it have static storage duration and external linkage?
     
    Ayrosa, Apr 29, 2014
    #1
    1. Advertisements

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. Neil Zanella
    Replies:
    1
    Views:
    5,807
    Arvind Kumar
    Jul 8, 2003
  2. GlennH
    Replies:
    1
    Views:
    1,296
    Mike Treseler
    Jul 11, 2003
  3. steve.leach

    How standard is the standard library?

    steve.leach, Apr 18, 2005, in forum: Python
    Replies:
    1
    Views:
    600
    Christos TZOTZIOY Georgiou
    Apr 18, 2005
  4. funkyj
    Replies:
    5
    Views:
    1,497
    funkyj
    Jan 20, 2006
  5. Replies:
    5
    Views:
    1,137
  6. Sriram Srinivasan
    Replies:
    13
    Views:
    932
    Benjamin Kaplan
    Nov 12, 2009
  7. Venks
    Replies:
    5
    Views:
    513
    Ken Bloom
    Dec 6, 2007
  8. Xeno Campanoli / Eskimo North and Gmail
    Replies:
    2
    Views:
    359
    Phlip
    May 5, 2010
Loading...