November 5, 2025
Kafka-coded compile-time chaos
Recursive macros in C, demystified (once the ugly crying stops)
Genius or meltdown: devs split over C macro recursion
TLDR: A deep dive shows how to coax recursion out of C’s cranky preprocessor, the code-rewriting stage of compiling. Commenters split between clever hacks that auto-check code and fears of build systems stuck in infinite loops, with a few veterans saying 'just don't'.
The author calls the C preprocessor — the little robot that rewrites your code before it compiles — “Kafka” territory and admits to “ugly crying,” then shows how to tease out recursion, a looping trick the system basically forbids. And the crowd goes wild. One camp cheers the cleverness: finally a way to auto-generate checks and code without human mistakes. Another camp clutches pearls: please do not summon demons at compile time. A practical voice asks, “Can this turn MACRO into multiple functions?” while link-drops erupt as hackers flex with Preprocessor Iceberg — yes, a slide-sized “revive the macro” hack. The lore nerds show up too, citing Dave Prosser’s pseudocode to explain how macros really behave, which isn’t even in the official rulebook. Then comes the drama: one veteran confesses they tried writing a preprocessor and quit, and a security-minded commenter frets this could become a denial-of-service (DoS) situation — a build stuck looping forever. Memes fly about “compile-time voodoo” and “GCC séances,” while pragmatists roll their eyes: use it to avoid bugs, but don’t make your coworkers cry. Verdict? Half “galaxy brain,” half “do not touch,” all extremely caffeinated energy.
Key Points
- •C macros are subtle and difficult, generally best for light wrappers rather than complex logic.
- •Macros are currently C’s only compile-time execution mechanism and are crucial for many systems.
- •C macros cannot be easily called recursively; recursion in the macro system is limited.
- •The historical reason for the lack of recursion in macros is unclear and likely rooted in early practical evolution.
- •The article motivates techniques to cope with the preprocessor’s lack of iteration and recursion for tasks like checks and code generation.