| Deutsch English Français Italiano |
|
<20250317131418.597@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: __func__ is not a keyword Date: Mon, 17 Mar 2025 20:31:27 -0000 (UTC) Organization: A noiseless patient Spider Lines: 47 Message-ID: <20250317131418.597@kylheku.com> References: <vr4lgu$63fu$1@dont-email.me> <87bju2htxy.fsf@nosuchdomain.example.com> <6sCBP.1140938$t84d.713135@fx11.iad> <87bju0x10g.fsf@nosuchdomain.example.com> <20250316115725.530@kylheku.com> <8734fcwwhf.fsf@nosuchdomain.example.com> <20250317095147.230@kylheku.com> <87y0x3v2qe.fsf@nosuchdomain.example.com> Injection-Date: Mon, 17 Mar 2025 21:31:27 +0100 (CET) Injection-Info: dont-email.me; posting-host="9eb98ac983869514f441a96c41207106"; logging-data="913606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lRlln1V3JfI2M5Olt5rfng9X2JsWniSg=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:0zll0Fv8F1rtyodKbH/XDXE4wUk= On 2025-03-17, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > Kaz Kylheku <643-408-1753@kylheku.com> writes: >> On 2025-03-16, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >>> Are you suggesting that a conforming compiler must accept the above >>> code (defining __func__ in an inner scope)? If so, I disagree. >> >> I was initially divided on this one. >> >> On the one hand, inside a function, __func__ is not reserved (for future >> use); it is described as being bound as a variable name, and that makes >> it compatible with lexical shadowing. > > That's where I disagree, though I'm not 100% certain. > > Identifiers starting with __ are not conditionally reserved, and > they're not reserved "for future use". They're simply "reserved > for any use". I completely agree now. Part of the cocept of an identifier being "reserved" is that the implementation itself can refer to the identifier, blindly assuming that the identifier is defined as documented, and has not been shadowed or tampered with. OK, that being said, since __func__ is described in a certain way, namely *as-if* this declaration followed the opening brace of the function:: static const char __func__[] = "function-name"; I think that legitimizes the program using expressions like: sizeof __func__ with the expectation that this yields the number of characters oin the function name, plus one. That will obviously not work if the implementation takes some license, and makes the implicit declaration as if it were: static const char *func = "function-name"; -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca