logoalt Hacker News

Fun Extending the C Preprocessor

34 points • by david2ndaccount • last Thursday at 5:08 PM • 10 comments • view on HN

Comments

teo_zero • today at 7:08 AM

There are a couple of constructs that you end up re-creating as soon as you need non-trivial preprocessing.

One of those is the two-stage CAT, another one is the NARG the article talks about.

__COUNTER__ is going to be added to C29, the next version of the standard, maybe there's hope for __VA_COUNT__ and __CAT__ too!

➕ show 1 reply
HexDecOctBin • today at 8:34 AM

Has anyone tried to extend the C Preprocessor to be a fully turing complete language (perhaps something like Snobol) to allow for Terra like meta-programming?

(I am not talking about metalang99 or Cello like stuff, which exploits the Turing tarpit of the currently specified preprocessor but rather tasteful additions to the preprocessor itself).

➕ show 1 reply
pajko • yesterday at 5:40 AM

You don't need to extend the preprocessor to have MAP: https://github.com/swansontec/map-macro

➕ show 1 reply
rwmj • today at 10:31 AM

String comparison in #if would be nice ...

AtalantaDB • today at 8:54 AM

[flagged]