3
votes

From the C18 standard (6.7.9):

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 have no problem with block scope + external linkage. But, I can't see how can an identifier have block scope and internal linkage. Is that even possible?

1

1 Answers

6
votes

If your global is defined

static int hui;

it has internal linkage. Then

void f(void) {
    extern int hui;

}

refers to the same object with internal linkage, even if the keyword says extern.

So extern is a misnomer and should probably be linkage or so.