Go to main content
Oracle® Developer Studio 12.6: C++ User's Guide

Exit Print View

Updated: July 2017

4.10 Using the Predefined __func__ Symbol for Function Name

The compiler implicitly declares the identifier __func__ in each function as a static array of const char. If the program uses the identifier, the compiler also provides the following definition where function-name is the unadorned name of the function. Class membership, namespaces, and overloading are not reflected in the name.

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

For example, consider the following code fragment.

#include <stdio.h>
void myfunc(void)
  printf("%s\n", __func__);

Each time the function is called, it will print the following to the standard output stream.


The identifier __FUNCTION__ is also defined and is equivalent to __func__.

Note -  In C++11, __func__ is a standard symbol.