Path: csiph.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: question about linker Date: Wed, 04 Dec 2024 08:38:53 -0800 Organization: A noiseless patient Spider Lines: 49 Message-ID: <86a5dbmmhu.fsf@linuxsc.com> References: <87plmfu2ub.fsf@nosuchdomain.example.com> <87frnbt9jn.fsf@nosuchdomain.example.com> <877c8nt255.fsf@nosuchdomain.example.com> <20241129142810.00007920@yahoo.com> <20241129161517.000010b8@yahoo.com> <87ldwx10gv.fsf@bsb.me.uk> <874j3j1ywx.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Wed, 04 Dec 2024 17:38:56 +0100 (CET) Injection-Info: dont-email.me; posting-host="24be5a3bcc5136b6a89c55a2b150290e"; logging-data="1044757"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/3KdgpQxHyfehuqldCtwsw1yrVVZHLgU=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:3ULwI7mk+uuAdxlSD7CUGyj7RX4= sha1:Yp7UExzjT48yAp+pxy5evepzCCU= Xref: csiph.com comp.lang.c:389354 Ben Bacarisse writes: > Bart writes: > >> On 03/12/2024 11:15, Ben Bacarisse wrote: >> >>> Bart 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.