make assertions opt-in (#447)

slight addendum to 657080a7e5

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>
This commit is contained in:
NRK 2023-05-26 07:06:17 +00:00
parent 0e1bc3c045
commit 40480596ca
2 changed files with 5 additions and 1 deletions

View File

@ -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`

View File

@ -20,6 +20,10 @@
#ifndef NSXIV_H
#define NSXIV_H
#if !defined(DEBUG) && !defined(NDEBUG)
#define NDEBUG
#endif
#include <stdbool.h>
#include <stddef.h>