Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Formatted debug traces on win32
#pragma once
// <DEBUG WIN32 SNIPPET...
__pragma(warning(push, 1))
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
__pragma(warning(pop))
#include <sstream>
struct Win32Debug
{
mutable std::ostringstream msg;
template <typename T>
friend std::ostream& operator<<(const Win32Debug& debug, T datum) {
return debug.msg << datum;
}
~Win32Debug() {
OutputDebugStringA(msg.str().c_str());
}
};
// ...DEBUG WIN32 SNIPPET>
void debug_example() {
Win32Debug() << isQuantizedStartTime << isQuantizedDuration << isNonZeroDuration << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment