Re: Brief C23 excursion
Matthias Andree via Mutt-dev <[email protected]>
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <[email protected]> |
Am 16.04.26 um 12:34 schrieb Kevin J. McCarthy: > On Thu, Apr 16, 2026 at 08:38:50AM +0200, Matthias Andree via Mutt-dev > wrote: >> Am 16.04.26 um 06:52 schrieb Kevin J. McCarthy: >>> >>> So... I guess this is C23. Which I know almost nothing about :-D. >>> In any case, we're a long ways away from getting to that level of C >>> standard support in Mutt. >> >> It's actually a C11 feature that is finally leveraged in the C23 >> stdlib.h, see https://en.cppreference.com/w/c/language/generic.html >> or >> https://stackoverflow.com/questions/9804371/syntax-and-sample-usage-of-generic-in-c11 >> or >> https://learn.microsoft.com/en-us/cpp/c-language/generic-selection?view=msvc-170 > > Thank you, Matthias. Those links are really helpful. Starts to turn > line noise into something I can understand! Hi Kevin, My pleasure, glad to have helped -- and the "magic" is one major selling point for upgrading from C99 or older to at least C11 that I learned earlier today, and tells me the const correctness problem that fraught some of the stdlib.h functions is also a good reason to not wait for C23 for too long if you can assume up-to-date toolchains on the consumer side. (I had been more focused on tackling C++ version differences in the 11/14/17/20 range migrations lately, I didn't follow C much, also because the type generic stuff in C99/C11 is most prominently documented in the tgmath.h area where a generic function name works for float, double, long double so you needn't mess with whether you need fabs for a double, fabsf for float or fabsl for long double... had missed that it would also help with the void * vs. const void *). >> 1. C23 CHANGES INCOMPATIBLY how a function _declaration_ without >> arguments is interpreted. >> >> As of C23, int func() means the same as int func(void), must/will not >> take arguments, where C18 and before interpreted "has no prototype, >> any number of arguments is fine", although that had been deprecated >> since C99 or so. > > It wasn't that long ago that I start converting some func() > declarations inside mutt to func(void). I'll count myself lucky that > we didn't happen to have those kinds of problems in our configure.ac too! > Yep, that cleanup pretty much avoided the impenetrable "fails to compile on <moderndistro>" reports or "fails to compile on GCC15". Cheers, Matthias