This should be trivial but I cannot seem to figure out how to concatenate __FUNCTION__ with strings especially on GCC -- although it works on VC++ (I'm porting some code to Linux)
#include <iostream>
#include <string>
#define KLASS_NAME "Global"
int main()
{
std::string msg = KLASS_NAME "::" __FUNCTION__;
std::cout << msg << std::endl;
}
GCC error message
Test.cpp:9:36: error: expected ‘,’ or ‘;’ before ‘__FUNCTION__’
std::string msg = KLASS_NAME "::" __FUNCTION__;
Update
Thanks to Chris, apparently adjacent string literals are concatenated [reference]. So VC++ may be correct in this case, until you consider that __FUNCTION__ is non-standard.
__FUNCTION__isn't standard and that__func__isn't a string literal.KLASS_NAME "::" __FUNCTION__if its not valid? I'm assuming its not.