Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block scope and internal linkage?

Tags:

c

linkage

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?

like image 915
Pep Avatar asked Sep 16 '25 20:09

Pep


1 Answers

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.

like image 151
Jens Gustedt Avatar answered Sep 19 '25 07:09

Jens Gustedt