6

I have many different functions, and they all have simple printf statements using __func__ similar to this one:

printf("%s - hello world!", __func__);

Now the problem I am running into is that in some functions it returns <unknown> instead of the function name.

Why is that? Am I doing something wrong? AFAIK __func__ is a part of c99 so I don't understand why it isn't working as advertised.

I am using GCC 4.7.2 in Debian.

4

1 回答 1

2

听起来您包含的标头必须执行与此错误类似的操作并定义__func__如下:

define __func__ "<unknown>"

因此,只有在包含该标题时才能看到它。对此进行测试的一种快速方法是在不起作用__FUNCTION__的代码部分中使用。__func__然后你需要缩小范围,找出哪个标题有麻烦的逻辑并修复它。

于 2013-08-02T12:52:40.053 回答