With gcc versions up to 3.3 and with the MS compiler, I use the following macro:
DEBUG_WARNING(...) printf(">WARNING: "__FUNCTION__"() " __VA_ARGS__);
Using:
DEBUG_WARNING("someFunction returned %d", ret);
Output:
>WARNING: Class::FunctionName() someFunction returned -1
It is extremely convenient when we have many systems, all sending data. Its a one-line macro that allows us to filter the output accordingly. Small code, great use, nice to me.
As the definition of __FUNCTION__ (and __func__ in C ++) changed (to make it conform to standards), it also made this macro inoperative.
I have work using a function that builds a string manually, but I like my macro.
I skipped the easy way to get this simple single line macro that still works under Gcc 3.3?
: D
source share