c++visual-studio-2008winapioutput-window

Visual Studio Output Window Error - C++


Using Visual Studio 2008, I keep seeing this error in the output window:

_CrtDbgReport: String too long or IO Error

I have a lot of TRACE macros scattered throughout my code used to dump information about error conditions: file path, line number, error, etc. I need to trace down the source of this error because it may be that information it is trying to dump to the output window is too long. What is the maximum length of the string the TRACE macro can accept? Here is an example of how I typically use this macro:

TRACE(_T("CreateNotifyWindow : Failed to create handle for notify window thread.\r\n\tError: %d\r\n\tFile: %s\r\n\tLine: %d\r\n"), ::GetLastError(), _T(__FILE__), __LINE__);

Any thoughts would be appreciated. Thanks.


Solution

  • Ultimately I'll bet the problem is passing an object string instead of string.c_str() to the Macro. TRACE uses variadic argument passing to, ultimately, something that calls something in the vsnprintf() family for %s processing. It cannot deal with objects because C can not.

    The maximum length for OutputDebugString is 4K bytes minus a fraction, due to the implementation.