I am trying to make a print function which prepends the print statement with file, function, and line number.
The macro debug("test %d", 1)
should print:
[src/main.cpp:main():8] test 1
This answer claims to do what I want, and almost does it, but doesn't work as-is. (And the question is not the same as this one) Using that answer, I was able to come up with this macro:
#include <cstdio> //needed for printf
#define debug(a, args...) printf("[%s:%s():%d] " #a "\n", __FILE__, __func__ , __LINE__, ##args)
This is extremely close to what I want, but adds quotes around the string, like below. How can I print without the quotes?
[src/main.cpp:main():8] "test 1"