Krolyxon
Commit 4048059

Branches

Refs →

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.
Author
NRK
Date
2023-05-26 07:06 +0000
Parent
0e1bc3c
Commit
40480596cad8654dca225e7fb136f4151f5df5c0

+5 −1

2 files changed

  1. M config.mk +1 −1
  2. M nsxiv.h +4 −0
M config.mk View
@@ -26,7 +26,7 @@ CC = c99
2626 # CFLAGS, any additional compiler flags goes here
2727 CFLAGS = -Wall -pedantic -O2 -DNDEBUG
2828 # 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
3030 # LDFLAGS = $(CFLAGS)
3131
3232 # icons that will be installed via `make icon`
M nsxiv.h View
@@ -20,6 +20,10 @@
2020 #ifndef NSXIV_H
2121 #define NSXIV_H
2222
23+#if !defined(DEBUG) && !defined(NDEBUG)
24+ #define NDEBUG
25+#endif
26+
2327 #include <stdbool.h>
2428 #include <stddef.h>
2529