Created
July 12, 2015 12:45
-
-
Save tomaslibal/3a9b04a97ae3d1b2373f to your computer and use it in GitHub Desktop.
DEBUG PRINT in C as a macro
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
// From the TRE package | |
#ifdef TRE_DEBUG | |
#include <stdio.h> | |
#define DPRINT(msg) do {printf msg; fflush(stdout);} while(/*CONSTCOND*/(void)0,0) | |
#else /* !TRE_DEBUG */ | |
#define DPRINT(msg) do { } while(/*CONSTCOND*/(void)0,0) | |
#endif /* !TRE_DEBUG */ | |
// Updated for my use | |
#define APP_DEBUG 1 | |
#ifdef APP_DEBUG | |
#define DEBUGPRINT(...) fprintf(stdout, __VA_ARGS__) | |
#define PRNTSTR(val,name) \ | |
printf("%s = %s\n", name, val); | |
#else /* !APP_DEBUG */ | |
#define DEBUGPRINT(...) | |
#define PRNTSTR(...) | |
#endif /* !APP_DEBUG */ | |
// Inspiration from http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc09cpxmac.htm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment