Created
February 17, 2023 20:23
-
-
Save m1lkweed/88b6dec4cb7c6026e38094a409fcd153 to your computer and use it in GitHub Desktop.
Macro that tries to check assertions at runtime and compile-time
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
// (c) M1lkweed, 2022-2023 | |
// GPLv3+ | |
#include <assert.h> | |
#define ALWAYS_ASSERT(cond, ...) ({static_assert(__builtin_constant_p((cond))?(cond):1,##__VA_ARGS__);assert((cond),##__VA_ARGS__);}) | |
int main(int argc, char**){ | |
ALWAYS_ASSERT(argc > 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment