c++visual-studio-2010winapioutputdebugstring

OutputDebugString error


I use:

OutputDebugString(L"My error");

in Visual Studio 2010, but instead of displaying "My error", I get just an "ERROR" in the window.

enter image description here

How do I fix this issue?


Solution

  • Since you're explicitly passing an UNICODE string, I'd suggest you also explicitly call OutputDebugStringW().

    Otherwise, if the UNICODE preprocessor symbol is not defined in your compilation unit, the ANSI version of the function (OutputDebugStringA()) would end up being called with an UNICODE string, which it does not support, and it should result in a compilation error.

    EDIT: You cannot use OutputDebugString() to write a string in your application's status bar. OutputDebugString() only sends the string you pass to the debugger.

    You have to use the appropriate API to write text to the status bar instead. In your case, wxStatusBar::SetStatusText() should do the trick.