This is a legal language question in relation to the angle in the C11 standard.
The rules governing the relationship of an identifier in a C program are set out in clause 6.2.2 of standard C11. In particular, in 6.2.2 (5) it is stated that (my attention):
If the identifier declaration for a function does not have a storage class specifier, its binding is defined exactly as if it were declared using the storage class specifier extern
. If an identifier declaration for an object has a file scope and not a storage class specifier , its relationship is external.
In the case of an announcement, such as _Thread_local int a;
in the file area, 6.2.2 (5) above does not apply, because it _Thread_local
is a storage specifier. None of the other provisions of 6.2.2 applies, or (no static
therefore (3) does not apply, and not in the block area, is an object, not a parameter, therefore (6) is not applicable, etc.). And what should the connection a
comply with the Standard? Did I miss some other rules that define communication in this case?
I understand that the intention is to make him have an external connection (how does gcc view this case), but how does it follow from the Standard itself?
Note that itβs normal that there is an announcement like
static _Thread_local int a; extern _Thread_local int a;
, and in this case, rules 6.2.2 apply only to the fine when it a
has an internal binding (despite the fact that extern
).
Finally, semantics _Thread_local
are irrelevant here.
source
share