Saturday, 21 November 2009

MSVC++ Debug Output

I've been working on a multi-threaded Audio / Video / Network based browser plug-in recently and had a few threading-related synchronization issues to deal with. Break-points in multi-threaded apps are all well and good but when you have synchronisation issues that can potentially cause a browser crash, either a file-based logger or, preferably in my case, an IDE-based log of what happened is invaluable.

I've been a big GCC/G++ user for quite some time and haven't touched MSVC in a while so I was suprised when I had a lot of trouble tracking down the function used to output Debug information to the MSVC Output console so I thought I'd post it here to help out anyone with similar problems.

The functions you want are OutputDebugStringA or OutputDebugStringW. They're in winbase.h, included from windows.h. Their use is self explanatory.