Skip to content

Instantly share code, notes, and snippets.

@ygabo
Created March 10, 2014 00:15
Show Gist options
  • Save ygabo/9457195 to your computer and use it in GitHub Desktop.
Save ygabo/9457195 to your computer and use it in GitHub Desktop.
For pretty debug information on the callstack.
static int g_infoStackDepth = 0;
static vector<string> g_infoStack;
const int MaxInfoLength = 2056;
void push_info_stack(const string str)
{
g_infoStack.push_back(str);
}
void pop_info_stack()
{
g_infoStack.pop_back();
}
class InfoPushPopHelper
{
public:
InfoPushPopHelper(const string string)
{
push_info_stack(string);
}
~InfoPushPopHelper()
{
pop_info_stack();
}
};
#define INFO( format, ... ) \
char buffer[MaxInfoLength + 1]; \
_snprintf_s(buffer, MaxInfoLength + 1, format, __VA_ARGS__); \
InfoPushPopHelper infoPushPop(buffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment