Created
February 15, 2022 19:12
-
-
Save petewarden/b6a4c471b84e4a80712d832124b6138b to your computer and use it in GitHub Desktop.
Header file for simple variable tracing macros
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
#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