Search code examples
clanguage-lawyerc11linkage

When can a declaration of an identifier that has block scope have internal linkage?


I was shifting around the 'C' standard and I came across this:

$6.7.9.5:

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.

So my question is on the title. I would also like some examples if possible.


Solution

  • static int i; // internal linkage
    
    void f() {
       extern int i; // block-scope declaration; refers to i in global scope
                     // still internal linkage - see 6.2.2/4
    }