Predefined identifiers

Previous Table of Contents "New C Standard" commentary

810 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.61)

811 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.

812 EXAMPLE Consider the code fragment:

        void myfunc(void)
                printf("s\n", __func__);
                /* ... */

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


813 Forward references: function definitions (6.9.1).

814 61) Since the name __func__ is reserved for any use by the implementation (7.1.3), if any other identifier is explicitly declared using the name __func__, the behavior is undefined.


Created at: 2008-01-30 02:39:41 The text from WG14/N1256 is copyright © ISO