3 ms·
This is the work of a wizard. I've known C for almost 20 years, and never would I have thought the macro system was powerful enough to allow such black magic.
by linkdd 2y ago
This is the work of a wizard.
I've known C for almost 20 years, and never would I have thought the macro system was powerful enough to allow such black magic.
This is awesome!
- lupire 2y agoADTs are mostly string replacement on generic structs and unions, plus tagging on the union. It's not a complicated use of macros.
- clnhlzmn 2y agoYou might also be interested in metalang99 by the same author.
- CuriousCosmic 2y agoYeah xmacros (the style of macro use) are pretty fancy. "Classically" they are used for creating and accessing type safe generics or for reducing boilerplate for hardware register and interrupt definitions. They are kind of cursed but at their core they are actually incredibly simple and a reliable tool for reducing cognitive complexity and boilerplate in C based projects.
- cl91 2y ago> I've known C for almost 20 years The author is only 19 years old. I feel really dumb now.