Skip to content

Instantly share code, notes, and snippets.

@alichtman
Last active June 2, 2020 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alichtman/e14345c9ae7f3e54dbcadc6c60d6b535 to your computer and use it in GitHub Desktop.
Save alichtman/e14345c9ae7f3e54dbcadc6c60d6b535 to your computer and use it in GitHub Desktop.
Logging Macros in C
#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