News for hackers. Stuff that matters.
Re:Scandalous Weird Old Things About The C Preprocessor (2015) by komerdoor on Tuesday May 30, 2017 @10:47AM (#14445731)
I once started experimenting with (GNU) C macros: https://gist.github.com/machuidel/d7cc099ddc4970c6ddf4

It became an abomination consisting out of many C-preprocessor hacks and impossible to debug. I never put it online (and I never will).

In the end if you want to use C at a more abstract level you may as well use Nim (not C, but it compiles to C89), C++ (of course) or write your own code generator (using libclang with annotations for ex.).

Re:Scandalous Weird Old Things About The C Preprocessor (2015) by FrozenVoid on Tuesday May 30, 2017 @01:30PM (#14446923)
D mixin templates/mixins are another alternative: You can include arbitrary strings from functions running at compile time. Theoretically they're more powerful than C macros, but type safety(template parameters) makes some constructs awkward - unless you create and parse strings as tokens manually(basically reading/writing many strings to achieve what C preprocessor does with symbolic token composition). https://dlang.org/mixin.html https://dlang.org/spec/template-mixin.html Templates can also include mixins: template liter(String s){mixin(s);}
Re:Scandalous Weird Old Things About The C Preprocessor (2015) by bachmeier on Tuesday May 30, 2017 @12:33PM (#14446493)
Or mix in a Scheme that compiles to C, like Gambit, Chicken, or Bigloo. You can leave the low level and performance sensitive stuff in C.