My calls to the TRACE macro are resulting in an error when I attempt to pass a string to it like so:
TRACE(_T("PrintAppMsgTrace: %s"), _T(GetCmdIdStr( pMsg[APP_MSG_CODE_OFFSET] )));
This is the error I get in the console window output:
_CrtDbgReport: String too long or IO Error
Here is the prototype for GetCmdIdStr:
char * GetCmdIdStr( BYTE id );
GetCmdIdStr returns a pointer to memory containing something like “APP_ZDO_NLME_LEAVE_REQ”. It essentially works like this:
char * GetCmdIdStr( BYTE id )
{
return "APP_ZDO_NLME_LEAVE_REQ";
}
Why am I getting this error? Any thoughts would be appreciated. Thanks.
The
_T()macro is used on string literals. It expands to either just the original string literal, if you’re compiling ANSI, or the string literal with anLprefix if you’re compiling UNICODE. You can’t apply it to the return value of a function.If possible, the simplest thing to do would be to change the
GetCmdIdStrfunction to returnTCHARinstead ofchar: