Sujet : Re: question about linker
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 04. Dec 2024, 17:38:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86a5dbmmhu.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Ben Bacarisse <
ben@bsb.me.uk> writes:
Bart <bc@freeuk.com> writes:
>
On 03/12/2024 11:15, Ben Bacarisse wrote:
>
Bart <bc@freeuk.com> writes:
...
>
If I write this
>
int *A, B[10], C(int);
>
My compiler tells me that:
>
A is a local variable [...]
B is a local variable [...]
C is a function with return type of 'i32', taking one
unnamed parameter of type 'i32'.
>
(Interestingly, it places C into module scope, so the same
declaration can also create names in different scopes!)
That means your compiler is not compiling standard C. In standard C
all entities declared locally have block scope, not file scope.
A small correction: that declaration gives all three names the
same scope[1].
>
This is what I observed my compiler doing, because it displays the
symbol table. It puts C into module-scope, so I can access it also
from another function without another declaration (so
non-conforming, but I'm long past caring).
>
You invented the term "module-scope" and that means you've lost
track of what the scope of a name is in C. [...]
To be fair, the C standard does use the phrase "file scope", and
mentions giving file scope to function identifiers (even locally
declared ones) as a common extension.
That doesn't invalidate your reaction to Bart's statement, because
he is being sloppy with language, and that deserves being pointed
out. The important point here, even though what is being done is
not standard C, is that a single declaration is putting names into
different /kinds/ of scopes. It would have been better if he had
said "different kinds of scopes" rather than just "different
scopes". Besides being wrong, what he did say raises the question
of whether he knows the difference.