diff options
| author | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
| commit | 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 (patch) | |
| tree | 158cfc17b2f644a10f063cb546752cfaae12c97f /devdocs/gcc~13/function-names.html | |
| parent | 9278ddd4ea1a8b1a4c1edaa8894516e3f48d245b (diff) | |
| download | dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.tar.gz dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.zip | |
removing all downloaded devdocs files
Diffstat (limited to 'devdocs/gcc~13/function-names.html')
| -rw-r--r-- | devdocs/gcc~13/function-names.html | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/devdocs/gcc~13/function-names.html b/devdocs/gcc~13/function-names.html deleted file mode 100644 index 56b88107..00000000 --- a/devdocs/gcc~13/function-names.html +++ /dev/null @@ -1,27 +0,0 @@ -<div class="section-level-extent" id="Function-Names"> <div class="nav-panel"> <p> Next: <a href="return-address" accesskey="n" rel="next">Getting the Return or Frame Address of a Function</a>, Previous: <a href="incomplete-enums" accesskey="p" rel="prev">Incomplete <code class="code">enum</code> Types</a>, Up: <a href="c-extensions" accesskey="u" rel="up">Extensions to the C Language Family</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="section" id="Function-Names-as-Strings"><span>6.50 Function Names as Strings<a class="copiable-link" href="#Function-Names-as-Strings"> ΒΆ</a></span></h1> <p>GCC provides three magic constants that hold the name of the current function as a string. In C++11 and later modes, all three are treated as constant expressions and can be used in <code class="code">constexpr</code> constexts. The first of these constants is <code class="code">__func__</code>, which is part of the C99 standard: </p> <p>The identifier <code class="code">__func__</code> is implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">static const char __func__[] = "function-name";</pre> -</div> <p>appeared, where function-name is the name of the lexically-enclosing function. This name is the unadorned name of the function. As an extension, at file (or, in C++, namespace scope), <code class="code">__func__</code> evaluates to the empty string. </p> <p><code class="code">__FUNCTION__</code> is another name for <code class="code">__func__</code>, provided for backward compatibility with old versions of GCC. </p> <p>In C, <code class="code">__PRETTY_FUNCTION__</code> is yet another name for <code class="code">__func__</code>, except that at file scope (or, in C++, namespace scope), it evaluates to the string <code class="code">"top level"</code>. In addition, in C++, <code class="code">__PRETTY_FUNCTION__</code> contains the signature of the function as well as its bare name. For example, this program: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">extern "C" int printf (const char *, ...); - -class a { - public: - void sub (int i) - { - printf ("__FUNCTION__ = %s\n", __FUNCTION__); - printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__); - } -}; - -int -main (void) -{ - a ax; - ax.sub (0); - return 0; -}</pre> -</div> <p>gives this output: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">__FUNCTION__ = sub -__PRETTY_FUNCTION__ = void a::sub(int)</pre> -</div> <p>These identifiers are variables, not preprocessor macros, and may not be used to initialize <code class="code">char</code> arrays or be concatenated with string literals. </p> </div> <div class="nav-panel"> <p> Next: <a href="return-address">Getting the Return or Frame Address of a Function</a>, Previous: <a href="incomplete-enums">Incomplete <code class="code">enum</code> Types</a>, Up: <a href="c-extensions">Extensions to the C Language Family</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div><div class="_attribution"> - <p class="_attribution-p"> - © Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br> - <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Function-Names.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Function-Names.html</a> - </p> -</div> |
