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.
Add a comment |
1 Answer
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 1 Comment
John Dibling
+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