Wednesday, 15 February 2012

how to write to output window in Visual Studio 2013? -



how to write to output window in Visual Studio 2013? -

i able compile , run visual c++ program. not console application. modifying existing mfc application. trying troubleshoot program. cannot run in debug , traces need because programme reads mouse cursor. tried utilize messagebox output string, again, message box interferes mouse.

in output window, right-click , create sure programme output enabled.

cout << "something" << endl;

however, in output window, not see anything.

looking @ posts, tried

std::string stro = "something "; outputdebugstring(stro);

error c2664: 'void outputdebugstringw(lpcwstr)' : cannot convert argument 1 'std::string' 'lpcwstr'

so changed std::wstring stro

and

outputdebugstring(stro.c_str());

to append int, had to

std::wostringstream wso; wso << i; stro = stro + wso.str(); outputdebugstring(stro.c_str());

but cannot see output in window when not running in debug. there way see output in non-debug? surprisingly frustrating.

in comments, writing separate overloaded class suggested; seems overkill. java has system.out.println in gui programs. android has log.v(). such pity equivalent not available here.

console applications have console output, cout sends to. since isn't console application, you'll want seek approach. it's unusual object "i don't see debug output when i'm not in debug", that's point of - don't utilize outputdebugstring , expect other debug output.

i think best way understand application doing, without interacting under debugger (i know frustration of trying debug event handlers maintain beingness re-triggered debugging activities) seek tracepoints. blogged them in 2006 , they're still great technique. reading mouse cursor won't interfere tracepoints, , can turn them on , off without rebuilding app or making code changes.

set breakpoint, right-click reddish dot , take when hit. can adjust default message goes output window show values interested in - can phone call functions in trace message, can see in blog entry phone call size() method of collection. if necessary, can debug release build.

visual-studio visual-c++ visual-studio-2013

No comments:

Post a Comment