Skip to content

Instantly share code, notes, and snippets.

@Irdroid
Created February 3, 2025 05:38
Show Gist options
  • Save Irdroid/0116a07727f090fd0292c8ab73857930 to your computer and use it in GitHub Desktop.
Save Irdroid/0116a07727f090fd0292c8ab73857930 to your computer and use it in GitHub Desktop.
Debug macro in C
// ============================================================================
// Libraries, Definitions and Macros
// ============================================================================
#ifdef DEBUG
#include "stdio.h"
__xdata uint8_t buffer[20];
#define DBG(fmt, ...) sprintf(buffer, "%s: " fmt "\r\n", __func__, ##__VA_ARGS__); OLED_print(buffer);
#else
#define DBG(fmt, ...);
#endif
@Irdroid
Copy link
Author

Irdroid commented Feb 3, 2025

Usage: DBG("This is debug text %d\n", variable);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment