__FUNCTION__ and friends act strange in Xcode

It works

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

But this is not the case (Error Expected ')'):

printf(__PRETTY_FUNCTION__" body\n");

I cannot get the IDE to show me what it __PRETTY_FUNCTION__evaluates to determine why it does not work.

+3
source share
1 answer

__PRETTY_FUNCTION__not a macro . It behaves like a static variable created on the fly in this function.

The last paragraph in the link above reads:

. GCC 3.3 , C, __FUNCTION__ __PRETTY_FUNCTION__ ; char, . GCC 3.4 , __func__. ++ __FUNCTION__ __PRETTY_FUNCTION__ .

+7

All Articles