Deutsch   English   Français   Italiano  
<86cyeeqno0.fsf@linuxsc.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: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: __func__ is not a keyword
Date: Tue, 18 Mar 2025 10:00:31 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <86cyeeqno0.fsf@linuxsc.com>
References: <vr4lgu$63fu$1@dont-email.me> <87bju2htxy.fsf@nosuchdomain.example.com> <20250315234302.412@kylheku.com> <87frjdwdhu.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 18 Mar 2025 18:00:32 +0100 (CET)
Injection-Info: dont-email.me; posting-host="3aaf2946c6814f1ddcb293e1f2bb9377";
	logging-data="3036406"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19DSIXe4BY2gneuHDn23fU6vzqral81Mpg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:lhWVmb/fcwnXq8wp4benYoWE/VQ=
	sha1:oDXAjpcpLaztkomH6EjAHC3AlbQ=

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Kaz Kylheku <643-408-1753@kylheku.com> writes:
>
>> On 2025-03-15, Keith Thompson <Keith.S.Thompson+u@gmail.com> 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.

It seems more likely that they just don't care.  I expect there
has been very little demand for an option specifically to cover
this situation.

By the way, clang has -Wpredefined-identifier-outside-function,
along with the corresponding no- version to turn off the warning.