__func__ is not replaced in preprocessed output

I read about __FUNCTION__/ __func__in C / C ++ (they are used to print the name of the function in which they are used). Every place I read, they said that these are macros and are replaced during preprocessing. So, I explored this by seeing the pre-processed output using the command gcc -E prog.c. But I saw that they __func__were neither __FUNCTION__replaced by the function name by the preprocessor.

So is this a macro? If not, what is it and how is it implemented?

EDIT

I even tried it cpp prog.c. But still not replaced.

Also __ FILE__, __LINE__ and __FUNCTION__ use in C ++ this post says that it never affects performance. Please clarify.

+4
source share
2 answers

They are implemented as (and are) "magic variables". The manual states :

GCC provides three magic variables that contain the name of the current function as a string. The first of these is __func__, which is part of the C99 standard:

The identifier is __func__implicitly declared by the translator, as if immediately after opening the bracket of each function definition, the declaration

static const char __func__[] = "function-name";
Has appeared

where function-nameis the name of the lexically-embracing function. This name is the undisclosed function name.

; . , , , , , .

+7

__func__ , . __FUNCTION__ , __func__ , :

static const char __func__[] = "function-name";

static const char __func__[] = __FUNCTION__;

:

__func__ __FUNCTION__, .

http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2004/n1642.html

+6

Source: https://habr.com/ru/post/1570841/


All Articles