i earlier used the __FILE__ and __FUNCTION__ macros a lot in debugging usages today i discovered __PRETTY_FUNCTION__ which really is special when one is using function overloading. basically the entities __XXX__ are replaced by the preprocessor to the value of these things before the compilation process.
Compile and run the following program to understand what they mean and how they function
using namespace std ;
cout << “Hello there from line number ” << __LINE__ << endl ;
cout << “the name of this file is ” << __FILE__ << endl ;
cout << “the name of this function is ” << __FUNCTION__ << endl ;
cout << “the pretty version name of this function is ” << __PRETTY_FUNCTION__ << endl ;
return 0 ;
i want to get hold of the list of all such predefined macros but can’t find any 😦
also the manual of current version of the gcc preprocessor does not list __PRETTY_FUNCTION__ or may be i haven’t looked properly yet !
oh yes __PRETTY_FUNCTION__ is most useful/meaningful in c++ …
a word of warning …
may be you should not call them macros due to the following reasons stolen from this source :
These identifiers are not preprocessor macros. In GCC 3.3 and earlier, in C only, __FUNCTION__ and __PRETTY_FUNCTION__ were treated as string literals; they could be used to initialize char arrays, and they could be concatenated with other string literals. GCC 3.4 and later treat them as variables, like __func__. In C++, __FUNCTION__ and __PRETTY_FUNCTION__ have always been variables.
looks like the world is conspiring against my ill-equipped brain 😦