Fun Extending the C Preprocessor

(davidpriver.com)

25 points | by david2ndaccount 2 days ago

4 comments

  • HexDecOctBin 1 hour ago
    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).

  • teo_zero 2 hours ago
    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!

  • pajko 1 day ago
    You don't need to extend the preprocessor to have MAP: https://github.com/swansontec/map-macro
    • david2ndaccount 19 hours ago
      The article shows how to implement map, but it should be a builtin
  • AtalantaDB 1 hour ago
    [flagged]