__FUNCTION__ and friends act weird in Xcode

c++, c-preprocessor, clang, function, xcode

Solution

`__PRETTY_FUNCTION__` is not a macro. It behaves like a static variable created on the fly scoped in that function.

The last paragraph in the link above reads:

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.

Problem

This works ``` printf("%s body\n",__PRETTY_FUNCTION__); ``` But this does not (Error `Expected ')'`): ``` printf(__PRETTY_FUNCTION__" body\n"); ``` I can't get the IDE to show me what `__PRETTY_FUNCTION__` evaluates to to determine why it does not work.

Original source

Related problems