__PRETTY_FUNCTION_ 以及C++中调用C
linux@ubuntu:~/linux_c$ cat example.c
#include <stdio.h>
int main(void)
{
printf("hi main=%s %s\n",__FUNCTION__,__PRETTY_FUNCTION__);
printf("hi main=%s %s\n",__FUNCTION__,__func__);
return 0;
}
linux@ubuntu:~/linux_c$ cat test.cpp
#include <stdio.h>
extern "C" {
extern 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;
linux@ubuntu:~/linux_c$ g++ test.cpp -o dd
linux@ubuntu:~/linux_c$ gcc -g example.c
linux@ubuntu:~/linux_c$ g++ -g example.c
hi main=main main
In C, __PRETTY_FUNCTION__
is yet another name for __func__
. However, in C++, __PRETTY_FUNCTION__
contains the type signature of the function as well as its bare name
https://gcc.gnu.org/onlinedocs/gcc/Function-Names.html
文章来源: blog.csdn.net,作者:悟空胆好小,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/xushx_bigbear/article/details/48804665
- 点赞
- 收藏
- 关注作者
评论(0)