Skip to content

Instantly share code, notes, and snippets.

@ociotec
Created April 24, 2016 09:36
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 ociotec/71d09cd33709e6b54e84aa2208f07e78 to your computer and use it in GitHub Desktop.
Save ociotec/71d09cd33709e6b54e84aa2208f07e78 to your computer and use it in GitHub Desktop.
Sample of simple macro to print log messages including the function & line where it's logged
#include <stdio.h>
#define PRINT(...) \
printf("%s():%03u ", __FUNCTION__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n");
int main()
{
PRINT("Hello world")
/* It should render:
main():009 Hello world */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment