Predefined Identifiers

The predefined identifier __func__ makes the function name available for use within the function. Immediately following the opening brace of each function definition, __func__ is implicitly declared by the compiler. The resulting behavior is as if the following declaration had been made:

static const char __func__[] = "function-name";

where function-name is the name of the lexically-enclosing function. The function name is not mangled.

When this identifier is used with the assert macro, the macro adds the name of the enclosing function on the standard error stream.

C++C++ supports the __func__ predefined identifier as a language extension for compatibility with C99.

The function name is qualified with the enclosing class name or function name. For example, foo is a member function of class C. The predefined identifier of foo is C::foo. If foo is defined within the body of main, the predefined identifier of foo is main::C::foo.

The names of template functions or member functions reflect the instantiated type. For example, the predefined identifier for the template function foo instantiated with int,

template<classT> void foo()

is foo<int>.

Related References

IBM Copyright 2003