I am using the following way to cout a function's time:
#define TIME_COST(message, ...)\
char szMessageBuffer[2048] = {0};\
va_list ArgList;\
va_start(ArgList, message);\
vsprintf_s(szMessageBuffer, 2048, message, ArgList);\
va_end(ArgList); \
string strMessage(szMessageBuffer);\
CQLogTimer t(strMessage);
// CQLogTimer is a self destructor,which will cout life time of its own and print szMessageBuffer.
However when I use the macro this :
void fun
{
TIME_COST("hello->%s", filePath);
XXXXXX
}
The message generated always is hello-(null)
Can Any one help?
Many thanks!