Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Cursed fire or #define black magic (ssloy.github.io)
34 points by davikr 5 months ago | hide | past | favorite | 5 comments


The new "__VA_TAIL__" proposal for C2Y [1] will make these sorts of tricks much more manageable. I love it and implemented it right away in slimcc.

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3307.htm


I wonder if at some point it would be better to adopt an already existing macro language like M4 instead of reinventing everything and adding a ton of features into the CPP.


m4 is filled with quirks of its own. I tried using it once for generating code in a language without macros, only to get bogged down in the opaque quoting rules. It's worse than the \expandafter soup you get in TeX macros.

Also, you'd have a hard time finding a pair of quote characters that don't conflict with C/C++ source code, since string literals can contain just about anything. Any general-purpose preprocessor should at least conform to the lexical rules of the target language.


Is there a saner macro language out there, or is this due to the intrinsic complexity of macro languages?


thought this was gonna be a write up from someone involved in burning Santa Monica :)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: