c++ - __FUNCTION__ 和 friend 在 Xcode 中表现得很奇怪

标签 c++ xcode function clang c-preprocessor

这行得通

printf("%s body\n",__PRETTY_FUNCTION__);

但这不是(错误 Expected ')'):

printf(__PRETTY_FUNCTION__" body\n");

我无法让 IDE 向我展示 __PRETTY_FUNCTION__ 的计算结果以确定它为何不起作用。

最佳答案

__PRETTY_FUNCTION__ is not a macro .它的行为类似于在该函数范围内动态创建的静态变量。

上面链接的最后一段是这样的:

These identifiers are not preprocessor macros. In GCC 3.3 and earlier, in C only, __FUNCTION__ and __PRETTY_FUNCTION__ were treated as string literals; they could be used to initialize char arrays, and they could be concatenated with other string literals. GCC 3.4 and later treat them as variables, like __func__. In C++, __FUNCTION__ and __PRETTY_FUNCTION__ have always been variables.

关于c++ - __FUNCTION__ 和 friend 在 Xcode 中表现得很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11142779/

相关文章:

c++将类成员函数添加到Map中

php - isset() 和 PHP 全局变量

c++ - 是否可以使函数在 C++ 中返回类型名?

c++ - 来自同一地址的 readelf 几乎重复的符号

c++ - Clang AST 将对 make_unique 的调用与特定类匹配

c++ - 如何在 AI Challenge Planet Wars 中运行四个机器人?

ios - 如何在iOS中的动画图像上放置按钮?

ios - Xcode - [UITableView _contentOffsetForScrollingToRowAtIndexPath :atScrollPosition:]: row (7) beyond bounds (0) for section (0).'

xcode - 用新项目替换旧项目

javascript - TypeError : this. props.* 不是函数