logoalt Hacker News

teo_zero • today at 7:08 AM • 1 reply • view on HN

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!


Replies

0c3ca83 • today at 10:26 AM

Doing non-trivial preprocessing is a mistake. You get slow compilation, hard to debug code, opaque and fragile code, and incredible complexity. If you want metaprogramming, you're better off with C++ it you need C header compatibility, or zig if you don't.

Otherwise, it's probably a good idea to pretend that the only preprocessing directive is #include. With constexpr, even #define is obsolescent.

➕ show 1 reply