Deutsch English Français Italiano |
<v2vi4t$3en8h$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: BGB <cr88192@gmail.com> Newsgroups: comp.lang.c Subject: Re: errno (was Re: C23 thoughts and opinions - why so conservative?) Date: Sun, 26 May 2024 09:48:58 -0500 Organization: A noiseless patient Spider Lines: 49 Message-ID: <v2vi4t$3en8h$1@dont-email.me> References: <v2l828$18v7f$1@dont-email.me> <20240523171911.00002f5a@yahoo.com> <v2o7re$1tlge$1@dont-email.me> <20240524003424.0000590a@yahoo.com> <v2qddg$2d33b$1@dont-email.me> <v2rc19$2i5ih$5@dont-email.me> <v2t174$2ue9j$1@dont-email.me> <875xv11mnb.fsf@nosuchdomain.example.com> <v2vgb9$3eaba$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 26 May 2024 16:49:01 +0200 (CEST) Injection-Info: dont-email.me; posting-host="395cbaf6175f5d948589fe56213a949c"; logging-data="3628305"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Rin2q+iihL2T4T/wNmD7pQiTN6tLFW7M=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:enaAwwNXsFOAgwR+DIYBJoPd4Bc= Content-Language: en-US In-Reply-To: <v2vgb9$3eaba$2@dont-email.me> Bytes: 2717 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: >> [...] >>> 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. >> > > 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. Well, granted, it is possible I could have misinterpreted how it was supposed to work and had never noticed... >>> 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()) >> > > >