Skip to content

Instantly share code, notes, and snippets.

@nil-ableton
Created January 26, 2017 13:56
Show Gist options
  • Save nil-ableton/9cd7b0f9fcbf5fd7ca852ead958be362 to your computer and use it in GitHub Desktop.
Save nil-ableton/9cd7b0f9fcbf5fd7ca852ead958be362 to your computer and use it in GitHub Desktop.
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