I am seeing some really weird errors in a complex file, and I suspect I have some include with namespaces left open, or something similar. I cannot compile some file to an executable state.
To figure out what is the problem, I wanted to print the current namespace. I thought I would be fine using something like __func__
(available since C++11) or __PRETTY_FUNCTION__
, but I cannot get to print it.
I cannot include it directly in a #pragma message(__func__)
("warning: expected a string after #pragma message"), and stringifying doesn't help, so namely, if I use this code:
#define STR_(x) #x
#define STR(x) STR_(x)
void fooMessage() {
#pragma message(STR(__func__))
}
I cannot get to print anything but the string "__func__"
. It seems to work for __LINE__
, but it's not useful for what I want to do...
Is there a way to have a pragma message to print the complete function name (or to know the current namespace) from clang and/or gcc compiler?
Some things I have tried are available here