HPlogo HP C/HP-UX Release Notes for HP-UX 11.01: HP 9000 Computers > Chapter 1 New and Changed Features

Predefined identifier__func__

» 

Technical documentation

Complete book in PDF

 » Table of Contents

The HP ANSI C compiler now defines the predefined identifier__func__, as specified in the C9X Standard. It has been added to HP C to provide you with additional means of debugging your code.

Syntax

The __func__ identifier is implicitly declared by the compiler in the following manner:

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

The above declaration is implicitly added immediately after the opening brace of a function which uses the variable __func__. The value <function-name> is the name of hte lexically-enclosing function. This name is the unadorned name of the function.

Example

The following code example fragment illustrates the use of predefined identifier__func__.

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

Each time the varfunc function is called, it prints to the standard output stream:

varfunc
© Hewlett-Packard Development Company, L.P.