Re: Initialization

Discussion in 'C Programming' started by Ben Bacarisse, Jan 24, 2013.

  1. Russell Shaw <rjshawN_o@s_pam.netspace.net.au> writes:

    > Hi,
    > In gcc-4.7 C99, this gets accepted in a block scope:
    >
    > static int a = 1;
    >
    > ISO/IEC 9899:201x 6.7.8p5 says:
    >
    > If the declaration of an identifier has block scope, and the
    > identifier has external or internal linkage, the declaration shall
    > have no initializer for the identifier.


    I think 6.2.2 p6 is the key thing here:

    "The following identifiers have no linkage: an identifier declared to
    be anything other than an object or a function; an identifier declared
    to be a function parameter; a block scope identifier for an object
    declared without the storage-class specifier extern."

    In your example, 'a' has no linkage. For block scope declarations,
    static alters only the lifetime of the object, not the linkage of the
    identifier.

    --
    Ben.
     
    Ben Bacarisse, Jan 24, 2013
    #1
    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. JKop
    Replies:
    10
    Views:
    995
  2. Matthias Kaeppler
    Replies:
    2
    Views:
    470
    Victor Bazarov
    Jul 18, 2005
  3. Replies:
    6
    Views:
    485
    Ron Natalie
    Dec 11, 2005
  4. toton
    Replies:
    5
    Views:
    950
    Victor Bazarov
    Sep 28, 2006
  5. Jess
    Replies:
    23
    Views:
    972
Loading...

Share This Page