News for hackers. Stuff that matters.
Re:Fun Extending the C Preprocessor by pajko on Saturday October 17, 2026 @01:40AM (#50128280)
You don't need to extend the preprocessor to have MAP: https://github.com/swansontec/map-macro
Re:Fun Extending the C Preprocessor by david2ndaccount on Saturday October 17, 2026 @10:44AM (#50131630)
The article shows how to implement map, but it should be a builtin
Re:Fun Extending the C Preprocessor by fuhsnn on Sunday October 18, 2026 @03:10PM (#50144254)
A builtin is definitely better for the efficiency alone. Vanilla chibicc needs 5GB to preprocess the example.c from map-macro, in comparison to compiling an amalgamation of itself only takes 50 MB. It of course wasn't optimized for memory use but it's a peak into how much token expansions are involved in the wizardry.
Re:Fun Extending the C Preprocessor by Neywiny on Sunday October 18, 2026 @09:30AM (#50140952)
But that repo says it's effortful for the preprocessor and you can see in the code it's a recursion limited but what's in the file. If you had, maybe, a few thousand register definitions in an embedded system, that won't do it.