aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-05-26 09:06:17 +0200
committerNRK <nrk@disroot.org>2023-05-26 09:06:17 +0200
commit40480596cad8654dca225e7fb136f4151f5df5c0 (patch)
treec03bd62682be982691268defed6835c537633518
parent0e1bc3c045384bca18922accbc50fa6914a67bd0 (diff)
downloadnsxiv-40480596cad8654dca225e7fb136f4151f5df5c0.tar.zst
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. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/447 Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
-rw-r--r--config.mk2
-rw-r--r--nsxiv.h4
2 files changed, 5 insertions, 1 deletions
diff --git a/config.mk b/config.mk
index 44ec692..20bb2b2 100644
--- a/config.mk
+++ b/config.mk
@@ -26,7 +26,7 @@ CC = c99
# CFLAGS, any additional compiler flags goes here
CFLAGS = -Wall -pedantic -O2 -DNDEBUG
# Uncomment for a debug build using gcc/clang
-# CFLAGS = -Wall -pedantic -g3 -fsanitize=address,undefined
+# CFLAGS = -Wall -pedantic -DDEBUG -g3 -fsanitize=address,undefined
# LDFLAGS = $(CFLAGS)
# icons that will be installed via `make icon`
diff --git a/nsxiv.h b/nsxiv.h
index 8011f9e..7e373c2 100644
--- a/nsxiv.h
+++ b/nsxiv.h
@@ -20,6 +20,10 @@
#ifndef NSXIV_H
#define NSXIV_H
+#if !defined(DEBUG) && !defined(NDEBUG)
+ #define NDEBUG
+#endif
+
#include <stdbool.h>
#include <stddef.h>