Liste des Groupes | Revenir à cl c |
On 26/05/2024 01:45, Keith Thompson wrote: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.David Brown <david.brown@hesbynett.no> writes:The second example was from the footnote in the C standard's section on <errno.h>, so it can't be /that/ bad!
[...]The normal way for multi-threaded systems is to implement it as a>
macro. It might be, for example :
>
#define errno __thread_data->_errno
>
or
>
#define errno *errno()
Both of those need more parentheses -- and I'm unconfortable using the
same identifier for the macro and the function.
>
But I agree with your discomfort.
That is precisely why it is specified in the C standards as a macro,[...]
not an external linkage object with static or thread-local storage
duration. (The use of errno in multi-threading C code long predates
C11 and _Thread_local.)
>
glibc and musl both have :
>
# define errno (*__errno_location ())
>
newlib (used on Cygwin) has something similar :
>
#define errno (*__errno())
>
Les messages affichés proviennent d'usenet.