Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: question about linker Date: Thu, 28 Nov 2024 18:15:39 -0800 Organization: None to speak of Lines: 43 Message-ID: <87v7w6ss38.fsf@nosuchdomain.example.com> References: <87plmfu2ub.fsf@nosuchdomain.example.com> <87frnbt9jn.fsf@nosuchdomain.example.com> <877c8nt255.fsf@nosuchdomain.example.com> <8734jbt07i.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 29 Nov 2024 03:15:40 +0100 (CET) Injection-Info: dont-email.me; posting-host="f64fae3639db49189bd8f4bb24b9887f"; logging-data="840809"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eIqU9eBX0ZJkjFwDMX3DZ" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:X6MGluUFZI+h83/mlZyxPnxmK+w= sha1:pgytfRuAXOlpoy6MEchw0AtBKrw= Bytes: 3012 Bart writes: > On 28/11/2024 23:20, Keith Thompson wrote: >> Bart writes: >>> On 28/11/2024 22:38, Keith Thompson wrote: > >>>>> T x; // defines a readonly variable (which probably needs >>>>> // initialising) >>>>> T* y; // defines a variable pointer >>>>> >>>>> 'const' is out of the picture. >>>> You say T is an alias (what, a macro?) for 'const int', you show code >>>> using T, and then you say "'const' is out of the picture". If you >>>> have a point, it escapes me. >>> >>> Well, can you see 'const' in my example? You can't tell x is readonly >>> by only looking at this. >> Yes, you said that T is an alias for 'const int'. Not sure why you >> wrote "alias". Is it a macro, or a typedef, or something else? >> I suggest that hiding "const" behind a macro or typedef is usually a >> bad idea. Why did you do it here? Is your example based on real >> code, or did you contrive it to be as confusing as possible? > > It's to illustrate that the constness of a variable may depend on > something which is remote from its declaration. > > Which is unlike how it usually works elsewhere. > > (And if it matters, the alias used a typedef.) > > For extra confusion, consider this version: > > T x, *y; > > The storage for x is read-only; for y it isn't. Or is it the other way > around? Yes, deliberately confusing code is confusing. Yes, different languages are different. Any problems with your code snippets can be solved by writing them more straightforwardly. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */