The compiler predefines two string variables to be the name of the current function. The variable __Function__ is the name of the function as it appears in the source. The variable __PRETTY_Function__ is the name of the function pretty printed in a language specific fashion.
These names are always the same in a C function, but in a C++ function they may be different. For example, this program:
extern "C" {
extern int printf (char *, ...);
}
class a {
public:
sub (int i)
{
printf ("__Function__ = %s\n", __Function__);
printf ("__PRETTY_Function__ = %s\n", __PRETTY_Function__);
}
};
int
main (void)
{
a ax;
ax.sub (0);
return 0;
}
gives this output:
__Function__ = sub __PRETTY_Function__ = int a::sub (int)
These names are not macros: they are predefined string variables. For example, “#ifdef __Function__” does not have any special meaning inside a function, since the preprocessor does not do anything special with the identifier __Function__.