Last active
June 2, 2020 09:44
-
-
Save alichtman/e14345c9ae7f3e54dbcadc6c60d6b535 to your computer and use it in GitHub Desktop.
Logging Macros in C
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
#define DEBUG 1 | |
#if DEBUG == 1 | |
#define LOG(...) fprintf(stderr, "\x1b[35m[%s:%d] \x1b[32m%s()\x1b[0m: ", __FILE__, __LINE__, __func__); fprintf(stderr, __VA_ARGS__) | |
#else | |
#define LOG(...) | |
#endif | |
int main(){ | |
int some_param = 2; | |
LOG("Value of some param: %zu bytes\n", some_param); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment