With gcc versions before 3.3 and with the MS compiler I use the following macro:
DEBUG_WARNING(...) printf(">WARNING: "__FUNCTION__"() " __VA_ARGS__);
Use:
DEBUG_WARNING("someFunction returned %d", ret);
Output:
>WARNING: Class::FunctionName() someFunction returned -1
Its extremely handy when we have lots of systems, all sending output. Its a single line macro, that allows us to filter the output accordingly. Small code, big use, happy me.
As the __FUNCTION__
(and __func__
in C++) definition has changed (to make it standards compliant I believe) it has also made that macro unworkable.
I've got it working using a function that builds the string by hand, but I like my macro.
Am I missing an easy way to get this simple one line macro to still work under Gcc 3.3?
: D