Last active
June 13, 2021 03:06
-
-
Save pervognsen/9d46bf9b9187cb7f89d64132dc586e07 to your computer and use it in GitHub Desktop.
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
void assert_func(int cond, const char *msg) { | |
if (!cond) { | |
fprintf(stderr, "assert failed: %s\n", msg); | |
abort(); | |
} | |
} | |
#define assert_helper(x, y, ...) assert_func(x, y) | |
#define assert(x, ...) assert_helper((x), ## __VA_ARGS__, #x) | |
int main(int argc, char **argv) { | |
assert(argc > 0); | |
assert(argv[0] != 0, "argv[0] cannot be null"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment