You must log in or register to comment.


emma wrote

you should be writing everything in macros, as macros are fast

#define THE_PROGRAM all \
    your \
    code \
    goes \

int main()

flabberghaster wrote

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.


flabberghaster wrote

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.


musou wrote

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.