Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 988
AnArrayOfFunctions Avatar asked Oct 30 '22 10:10

AnArrayOfFunctions


1 Answers

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
}
like image 88
T.C. Avatar answered Nov 08 '22 03:11

T.C.