News for hackers. Stuff that matters.
Re:New C features in GCC 13 by dzaima on Thursday May 04, 2023 @09:06AM (#35814642)
As an example of this, a generic `MAX` macro that doesn't evaluate its arguments multiple times, would be (using said GNU extension of statement expressions):

    #define MAX(A, B) ({ auto a = (A); auto b = (B); a>b? a : b; })
As-is, for such things I just use __auto_type, as it's already in the GNU-extension-land.
Re:New C features in GCC 13 by afdbcreid on Thursday May 04, 2023 @09:21AM (#35814851)
Do you really need to parenthesize the parameters? Is there something that can break the variable declaration into multiple statements?
Re:New C features in GCC 13 by dzaima on Thursday May 04, 2023 @09:25AM (#35814926)
Here, probably not (with proper arguments at least; without the parens something like `MAX(1;2, 3)` would compile without errors though), but I'm just used to doing it everywhere.
Re:New C features in GCC 13 by kps on Thursday May 04, 2023 @10:01AM (#35815465)
Here, no. It's just a habit or common style guideline to always parenthesize macro parameters since so many macros can otherwise break.
Re:New C features in GCC 13 by peterfirefly on Thursday May 04, 2023 @09:25AM (#35814925)
I wish ({...}) had been in C23.
Re:New C features in GCC 13 by uecker on Thursday May 04, 2023 @10:57AM (#35816395)
I agree, this is one of the more important common extensions we are still missing.
Re:New C features in GCC 13 by peterfirefly on Thursday May 04, 2023 @11:45AM (#35817241)
I'm still miffed it wasn't in C99 ;)
Re:New C features in GCC 13 by uecker on Thursday May 04, 2023 @12:19PM (#35817890)
Sorry, it was on my list of things to propose, but I did not have enough time (due to a job change). Others were more interested in lambdas.
Re:New C features in GCC 13 by peterfirefly on Thursday May 04, 2023 @12:30PM (#35818061)
You are forgiven. It must be like pushing water up a mountain. At least we got #embed, typeof, auto, constexpr, and sensible enums this time around.

How many of you guys have half of a C compiler lying around in a directory somewhere on your machines?

(And how do you find the time for WG14 AND writing code AND doing research? My cousin is in roughly the same field as you and you publish more than he does.)

Re:New C features in GCC 13 by uecker on Thursday May 04, 2023 @01:55PM (#35819502)
It is Sisyphean, but there also many synergies (I work on real-time computational imaging systems). And the specific things you mention were mostly not my work (I made typeof in GCC more coherent, which helped getting it standardized). But yes, I have a semi-complete C compiler around and many unfinished GCC branches...