在C语言中,预定义标识符__func__

在C语言中,预定义标识符__func__

标识符是在编程中给实体赋予的名称,以在程序中进行标识。

通常,标识符是由程序员创建的,以实现高效工作,但也有一些预定义的标识符内置在编程中。例如,cout、cin等。

在这里,我们将看到C编程语言中的一个预定义标识符__func__。

__func__的正式定义为 −

“标识符__func__应被翻译器隐式声明,就好像在每个函数定义的左花括号之后立即跟着声明一样。”

static const char __func__[] = “function-name”;登录后复制

C program The __func__ is a compiler-generated identifier that is created to identify the function using function name.

Let’s see a few code examples to make the concept more clear,

Example

Live Demo

#include void function1 (void){ printf ("%s

", __func__); function1 (); } int main (){ function2 (); return 0; }