Reputation: 14254
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.
Upvotes: 0
Views: 1407
Reputation: 944
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 an L
prefix 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 GetCmdIdStr
function to return TCHAR
instead of char
:
TCHAR * GetCmdIdStr( BYTE id )
{
return _T("APP_ZDO_NLME_LEAVE_REQ");
}
Upvotes: 1