Created
September 3, 2013 16:42
-
-
Save fclairamb/6426374 to your computer and use it in GitHub Desktop.
An evil way to test debug macro: ./debug.c BEGIN!
./debug.c:main:19: test!
./debug.c:main:20: test!
END !
BEGIN!
END !
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
#ifdef SHELL | |
gcc $0 && ./a.out | |
gcc -DNDEBUG $0 && ./a.out | |
exit 0 | |
#endif | |
#include <stdio.h> | |
#ifndef NDEBUG | |
#define DEBUG(fmt, arg...) \ | |
fprintf(stderr, __FILE__ ":%s:%d: " fmt,__FUNCTION__,__LINE__,##arg) | |
#else | |
#define DEBUG(fmt, args...) | |
#endif | |
int main( int argc, char * argv [] ) { | |
printf("BEGIN!\n"); | |
DEBUG("test!\n"); | |
DEBUG("%s", "test!\n"); | |
printf("END !\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment