macros are setting my hair on fire rn
Submitted by musou in programming
i'm trying to read this deprecated library code so i can replace it with something better and everything is macros and nothing is greppable aaaaaaaaaa please i have a family
Submitted by musou in programming
i'm trying to read this deprecated library code so i can replace it with something better and everything is macros and nothing is greppable aaaaaaaaaa please i have a family
The DRY principle says that if you write something more than once you should refactor it. Here I see you used ()
in two places; that can be a macro, to ease readability.
🚒 🚒 🚒 🚒 🚒
OK so this is kind of a pain in the neck to do a lot of times but sometimes you can get the output if the C preprocessor.
Then through careful editing, you can kind of figure out what it's turning in to.
int main(...) {
WEIRD_MACRO(1, 2);
}
Then you could just put comments above and below it, and run cpp -I/all/include/directories main.c
It will tell you the final output and also have debugging garbage about where each thing expanded from.
Not ideal, and also in a big project that uses a complex build tool it can be incredibly hard to get the cpp args, but it can help.
thanks for the helpful comments everybody. i'm writing Elixir instead of C in this case, but that just goes to show that you can have this problem in any language with macros. i remember feeling this way about some lisp code in the past, too.
emma wrote
you should be writing everything in macros, as macros are fast