本文介绍了关于使用C99 __func__宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

做这两件事情是一回事吗?


#define WHERE printf(" We in in%s" ,__ func__)

void函数(无效){

WHERE;

}


这个:


void函数(无效){

#define WHERE printf("我们在%s",__ func__)

WHERE;

}

-

Guillaume Dargaud


男人的手机是怎么回事?在一个剧院里,让他看起来越来越像Abe Lincoln? - Jerry L. Embry。

解决方案



C99中没有__func__。




是的。两者都扩展为:


void函数(无效){

printf(我们在%s,__ func__);


}



有。


6.4.2.2#1说:


标识符__func__应由翻译者隐式声明

,就像紧接每个函数的开头大括号

定义一样,声明


static const char __func __ [] =" function-name";


出现了,其中function-name是词法封闭的名称

功能。


-

OMG,-10 = = 10 in linux!




是的,因为__func__是必需的变得像一个变量,而不是
a预处理宏。


- 理查德


-

应考虑在一些字母表中需要多达32个字符

- 1963年的X3.4。


Hello all,
Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}
--
Guillaume Dargaud
http://www.gdargaud.net/
"What is it about a man''s cell phone going off in a theater that makes him
look more and more like Abe Lincoln ? - Jerry L. Embry.

解决方案

There''s no __func__ in C99.


Yes. Both expands to:

void Function(void) {
printf("We are in %s", __func__);

}

There is.

6.4.2.2 #1 says:

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.

--
OMG,-10==10 in linux!


Yes, because __func__ is required to be like a variable, rather than
a preprocessor macro.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


这篇关于关于使用C99 __func__宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 06:25