nsxiv4048059
make assertions opt-in (#447)
slight addendum to 657080a7e55843e351fa6ce41e4ce315eab62b67 instead of disabling asserts by adding -DNDEBUG to config.mk, this disables asserts by default in the source code itself. this way, if someone compiles with `make CFLAGS="-O3 -march=native"` without knowing about asserts/-DNDEBUG then he won't accidentally get a build with assertions in it. this basically makes the assertions opt-in, if someone wants it, he'll need to *explicitly* set `-DDEBUG` to get it. so that it's not possible to accidentally end up with assertions enabled.
+5 −1
2 files changed
| @@ -26,7 +26,7 @@ CC = c99 | |||
| 26 | 26 | # CFLAGS, any additional compiler flags goes here | |
| 27 | 27 | CFLAGS = -Wall -pedantic -O2 -DNDEBUG | |
| 28 | 28 | # Uncomment for a debug build using gcc/clang | |
| 29 | − | # CFLAGS = -Wall -pedantic -g3 -fsanitize=address,undefined | |
| 29 | + | # CFLAGS = -Wall -pedantic -DDEBUG -g3 -fsanitize=address,undefined | |
| 30 | 30 | # LDFLAGS = $(CFLAGS) | |
| 31 | 31 | ||
| 32 | 32 | # icons that will be installed via `make icon` | |
| @@ -20,6 +20,10 @@ | |||
| 20 | 20 | #ifndef NSXIV_H | |
| 21 | 21 | #define NSXIV_H | |
| 22 | 22 | ||
| 23 | + | #if !defined(DEBUG) && !defined(NDEBUG) | |
| 24 | + | #define NDEBUG | |
| 25 | + | #endif | |
| 26 | + | ||
| 23 | 27 | #include <stdbool.h> | |
| 24 | 28 | #include <stddef.h> | |
| 25 | 29 | ||