From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/gcc~13/function-names.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 devdocs/gcc~13/function-names.html (limited to 'devdocs/gcc~13/function-names.html') diff --git a/devdocs/gcc~13/function-names.html b/devdocs/gcc~13/function-names.html new file mode 100644 index 00000000..56b88107 --- /dev/null +++ b/devdocs/gcc~13/function-names.html @@ -0,0 +1,27 @@ +

6.50 Function Names as Strings ΒΆ

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 constexpr constexts. The first of these constants is __func__, which is part of the C99 standard:

The identifier __func__ is 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. This name is the unadorned name of the function. As an extension, at file (or, in C++, namespace scope), __func__ evaluates to the empty string.

__FUNCTION__ is another name for __func__, provided for backward compatibility with old versions of GCC.

In C, __PRETTY_FUNCTION__ is yet another name for __func__, except that at file scope (or, in C++, namespace scope), it evaluates to the string "top level". In addition, in C++, __PRETTY_FUNCTION__ contains the signature of the function as well as its bare name. For example, this program:

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;
+}
+

gives this output:

__FUNCTION__ = sub
+__PRETTY_FUNCTION__ = void a::sub(int)
+

These identifiers are variables, not preprocessor macros, and may not be used to initialize char arrays or be concatenated with string literals.

+

+ © Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
+ https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Function-Names.html +

+
-- cgit v1.2.3