__FUNCTION__和朋友在Xcode中行为怪异 [英] __FUNCTION__ and friends act weird in Xcode

查看:538
本文介绍了__FUNCTION__和朋友在Xcode中行为怪异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这项工作

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

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

printf(__PRETTY_FUNCTION__" body\n");

我无法让IDE显示 __ PRETTY_FUNCTION __ 求值以确定为什么它不工作。

I can't get the IDE to show me what __PRETTY_FUNCTION__ evaluates to to determine why it does not work.

推荐答案

__ PRETTY_FUNCTION __ 不是宏

上面链接中的最后一段是:

The last paragraph in the link above reads:


这些标识符不是预处理器宏。在GCC 3.3及更早版本中,仅在C中, __ FUNCTION __ __ PRETTY_FUNCTION __ 它们可以用于初始化char数组,并且它们可以与其他字符串字面连接。 GCC 3.4和更高版本将它们视为变量,如 __ func __ 。在C ++中, __ FUNCTION __ __ PRETTY_FUNCTION __ 始终是变量。

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.

这篇关于__FUNCTION__和朋友在Xcode中行为怪异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆