Contents|Index|Previous|Next
 Function names as strings   

GNU CC 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, like the following program. The program, then, gives the following output. 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__.

Top|Contents|Index|Previous|Next