Sujet : Re: errno (was Re: C23 thoughts and opinions - why so conservative?)
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 26. May 2024, 23:59:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v30ert$3le5u$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Mozilla Thunderbird
On 5/26/24 10:48, BGB wrote:
On 5/26/2024 9:18 AM, David Brown wrote:
On 26/05/2024 01:45, Keith Thompson wrote:
David Brown <david.brown@hesbynett.no> writes:
...
#define errno *errno()
>
Both of those need more parentheses -- and I'm unconfortable using the
same identifier for the macro and the function.
>
>
The second example was from the footnote in the C standard's section on
<errno.h>, so it can't be /that/ bad!
>
But I agree with your discomfort.
>
I would expect it to immediately explode, because AFAIK the usual
preprocessor behavior is to keep expanding macros in a line until there
is nothing left to expand.
No, C macros are not recursive:
"... The resulting preprocessing token sequence is then rescanned, along
with all subsequent preprocessing tokens of the source file, for more
macro names to replace.
If the name of the macro being replaced is found during this scan of the
replacement list (not including the rest of the source file’s
preprocessing tokens), it is not replaced. Furthermore, if any nested
replacements encounter the name of the macro being replaced, it is not
replaced. These nonreplaced macro name preprocessing tokens are no
longer available for further replacement even if they are later
(re)examined in contexts in which that macro name preprocessing token
would otherwise have been replaced." (6.10.4.4p1,2)