News for hackers. Stuff that matters.
Re:Metaprogramming custom control structures in C (2012) by ludocode on Saturday July 10, 2021 @03:45PM (#27795921)
But then your code can't be used by anyone without your preprocessor. There is a lot of value in plain C metaprogramming because it can be compiled with an ordinary C compiler.

You can, however, use a script to generate some of the preprocessor boilerplate while still having the templates configurable and instantiable with an ordinary C compiler. This is how my metaprogramming library Pottery works:

https://github.com/ludocode/pottery

It uses #include for templates rather than code block macros, something the article doesn't really go into. It's more powerful this way and the templates are far more readable; aside from the generated metaprogramming boilerplate, the templated code looks like (and preprocesses to) ordinary C.

There are no comments on this comment yet.