Deutsch English Français Italiano |
<vib23k$p0pn$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: question about linker Date: Fri, 29 Nov 2024 00:32:52 +0000 Organization: A noiseless patient Spider Lines: 38 Message-ID: <vib23k$p0pn$1@dont-email.me> References: <vi54e9$3ie0o$1@dont-email.me> <vi6sb1$148h7$1@paganini.bofh.team> <vi6uaj$3ve13$2@dont-email.me> <87plmfu2ub.fsf@nosuchdomain.example.com> <vi9jk4$gse4$1@dont-email.me> <vi9kng$gn4c$1@dont-email.me> <87frnbt9jn.fsf@nosuchdomain.example.com> <viaqh0$nm7q$1@dont-email.me> <877c8nt255.fsf@nosuchdomain.example.com> <viasv4$nm7q$2@dont-email.me> <8734jbt07i.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 29 Nov 2024 01:32:52 +0100 (CET) Injection-Info: dont-email.me; posting-host="4eb9340d280f8b52517112dd0afd3685"; logging-data="820023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NsvnsMBHNDb3HuEMXMOkg" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:QaIgEqDN524G52Wrs76GgKp9sHM= In-Reply-To: <8734jbt07i.fsf@nosuchdomain.example.com> Content-Language: en-GB Bytes: 2673 On 28/11/2024 23:20, Keith Thompson wrote: > Bart <bc@freeuk.com> 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?