Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: __func__ is not a keyword Date: Sun, 16 Mar 2025 02:06:53 -0700 Organization: None to speak of Lines: 27 Message-ID: <87frjdwdhu.fsf@nosuchdomain.example.com> References: <87bju2htxy.fsf@nosuchdomain.example.com> <20250315234302.412@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 16 Mar 2025 10:06:57 +0100 (CET) Injection-Info: dont-email.me; posting-host="780a281062e134e978cc3552b9df7fb5"; logging-data="1549606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CX+GsBo0dbci1GSovjnda" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Iz4tLPvA/xCyWa37Dq/nPWG9JbY= sha1:TQktzYb8AQcifXoBme/U7T79FvE= Xref: csiph.com comp.lang.c:391267 Kaz Kylheku <643-408-1753@kylheku.com> writes: > On 2025-03-15, Keith Thompson wrote: >> I'm mildly curious how gcc and clang treat "__func__" internally >> that leads to this odd behavior. The obvious way to implement it >> would be to internally create a declaration of __func__ on entry >> to each function definition, which shouldn't cause the symptom >> you're seeing. But it's not a conformance issue > > The main reason is this: > > "As an extension, at file (or, in C++, namespace scope), __func__ > evaluates to the empty string." But it produces a diagnostic warning: ‘__func__’ is not defined outside of function scope And in a very quick look through the documentation, I don't see a way to disable that warning (other than "-w", which disables all warnings). Looks like they don't really want you using this extension. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */