01-09-2016 04:59 PM
I am working on updating a CVI 8.5.1 program to CVI 2013 and have run into the issue that the __FUNCTION__ macro no longer works. There is quite a bit of code that depended on the string concatenation that would happen when you put __FUNCTION__ next to another quoted string
(ex printf(__FUNCTION__", this used to compile");
It now complains that it expected ')'.
When did this change again? They had fixed it in 8.5.1 (8.5 was broke also).
Solved! Go to Solution.
01-10-2016 08:25 AM
The LabWindows compiler has been replaced with clang. Clang is designed to be highly compatible with GCC. The GCC documentation (https://gcc.gnu.org/onlinedocs/gcc-3.3/gcc/Function-Names.html) states:
GCC 3.2 will handle __FUNCTION__ and __PRETTY_FUNCTION__ the same way as __func__. __func__ is defined by the ISO standard C99:
The identifier __func__ is implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration
static const char __func__[] = "function-name";
appeared, where function-name is the name of the lexically-enclosing function. This name is the unadorned name of the function.
By this definition, __func__ is a variable, not a string literal. In particular, __func__ does not catenate with other string literals.