How to define a macro to obtain the function name string, as follows:
//某一函数
void fun0(){
....
}
//宏定义
#define GET_NAME(fun) ....... // 这个怎么写
//获取 name=="fun0"
char *name = GET_NAME(fun0)
怪我咯2017-07-04 13:47:23
It’s very simple, I’ll give you some black technology:
#define CLASS_NAME(x) L#x
#define METHOD_NAME(x) L#x
#define LogInfo(str_class,str_method,str_format,...) \
Log(LogFilter::Info,METHOD_NAME(str_method),CLASS_NAME(str_class), str_format,__VA_ARGS__);
The Log method is defined like this:
void Log(LogFilter filter, wchar_t* classname, wchar_t* methodname, wchar_t* format, ...)