6.4.2.2 Predefined identifiers

Previous Table of Contents

805 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)

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

807 EXAMPLE Consider the code fragment:


        #include 
        void myfunc(void)
        {
                printf("s\n", __func__);
                /* ... */
        }

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

myfunc

808 Forward references: function definitions (6.9.1).

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

Next

Created at: 2005-06-29 02:18:57 The text from WG14/N1124 is copyright © ISO