3

I have a c# windows app that calls a managed c++ dll, which, in turn, calls a native c++ dll. There seem to be some performance issues in the native c++ code, so I'm doing some simple profiling. I'd like to dump the results of the profiling so that the Visual Studio output window picks it up. I thought that printf would do the trick, but nothing shows up in either the Output window or the Immediate window. I also tried fprintf, but that doesn't work either.

1 Answer 1

7

Try OutputDebugString

OutputDebugString is rather plain, so I tend to add the following to my projects to make it function like printf (making sure to avoid overrunning the buffer size):

#if (_VERBOSE) void DebugPrintf (LPTSTR lpFormat, ...) { TCHAR szBuf[1024]; va_list marker; va_start( marker, lpFormat ); _vstprintf( szBuf, lpFormat, marker ); OutputDebugString( szBuf ); va_end( marker ); } #endif 
Sign up to request clarification or add additional context in comments.

1 Comment

+1: Added benefit of using OutputDebugString(); you can view the messages in DbgView, which means you can view the messages even if your application is running in Release mode and not under the debugger

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.