Skip to content

Instantly share code, notes, and snippets.

@twopoint718
Last active February 18, 2022 21:01
Show Gist options
  • Save twopoint718/3f756f35705879a47f09e0f68c59fd6f to your computer and use it in GitHub Desktop.
Save twopoint718/3f756f35705879a47f09e0f68c59fd6f to your computer and use it in GitHub Desktop.
#ifndef INCLUDE_TRACE_H
#define INCLUDE_TRACE_H
#include <stdio.h>
#include <stdint.h>
#define TRACE_STR(variable) do { fprintf(stderr, __FILE__":%d "#variable"=%s\n", __LINE__, variable); } while(0)
#define TRACE_INT(variable) do { fprintf(stderr, __FILE__":%d "#variable"=%d\n", __LINE__, variable); } while(0)
#define TRACE_PTR(variable) do { fprintf(stderr, __FILE__":%d "#variable"=0x%016lx\n", __LINE__, (uint64_t)(variable)); } while(0)
#define TRACE_SIZ(variable) do { fprintf(stderr, __FILE__":%d "#variable"=%zu\n", __LINE__, variable); } while(0)
#endif // INCLUDE_TRACE_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment