Why can't a string literal be concatenated to __FUNCTION__?

Isn't __FUNCTION__ a string literal?

No.

From https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Function-Names.html

These identifiers are variables, not preprocessor macros, and may not be used to initialize char arrays or be concatenated with string literals.


Short answer, no, __FUNCTION__ is not a string literal, it's a pointer to a const char * variable containing the name of the function.

Because the __FUNCTION__ macro doesn't expand directly to the function name, instead, it expands to something like this (the exact name is probably different, but the name is stores as a pointer to char*):

 const char *func_name = "main";

 std::cout << func_name << std::endl;

And of course, if you have that code, it's quite easy to see that:

 std::cout << func_name "A" << std::endl;

will not compile.