Created
January 26, 2017 13:56
-
-
Save nil-ableton/9cd7b0f9fcbf5fd7ca852ead958be362 to your computer and use it in GitHub Desktop.
Formatted debug traces on win32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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