Thread: redefining variables without extern

  1. #16
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    Not to beat a dead horse, but to make sure:
    If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern. If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external.
    extern is thus indeed redundant on function declarations, but not on object declarations. Object declarations, without storage-class specifiers, at file scope (that is, external declarations) have external linkage, but are not assumed to have the storage-class specifier extern.

    Because the first sentence of the quote isn't relevant to the previous discussion I assume you quoted it for completeness, but I wasn't certain; hence this post.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by cas View Post
    Because the first sentence of the quote isn't relevant to the previous discussion I assume you quoted it for completeness
    Yes, that's right.

    Dave, thanks for the link.

    So if I have extern int i; at block scope, does that refer to a global variable unless there was a previous declaration of i at block scope? The extern int i; could be in an inner block and the previous declaration in an enclosing outer block, right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extern variables in GAS?
    By Kernel Sanders in forum C Programming
    Replies: 6
    Last Post: 10-20-2008, 10:10 PM
  2. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  3. problem with extern variables
    By crash88 in forum C Programming
    Replies: 11
    Last Post: 05-05-2006, 01:44 PM
  4. Odd Problem with Linking
    By jamez05 in forum C++ Programming
    Replies: 6
    Last Post: 09-21-2005, 01:49 PM
  5. extern symbols, what do these mean exactly?
    By Shadow12345 in forum C++ Programming
    Replies: 8
    Last Post: 11-02-2002, 03:14 PM