Created
April 24, 2016 09:36
-
-
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
This file contains hidden or 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
#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