jweinst1
3/21/2020 - 6:28 PM

Using a macro to trace the call of a function

Using a macro to trace the call of a function

#include <cstdio>

#define TRACED(name, ...) name(__VA_ARGS__) { \
      std::printf("Calling %s\n", #name);


int TRACED(add, int a, int b)
   return a + b;
}

int main() {
   int res = add(3, 4);
   return 0;
}