6.4.2.2 Predefined identifiers

Semantics

1

The identifier __func__ shall be implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration

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

appeared, where function-name is the name of the lexically-enclosing function.[1]

2

This name is encoded as if the implicit declaration had been written in the source character set and then translated into the execution character set as indicated in translation phase 5.

3

EXAMPLE Consider the code fragment:

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

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

myfunc

Forward References

Footnotes