Skip to content

Commit

Permalink
make assertions opt-in (#447)
Browse files Browse the repository at this point in the history
slight addendum to 657080a

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>
  • Loading branch information
N-R-K committed May 26, 2023
1 parent 0e1bc3c commit 4048059
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 4 additions & 0 deletions nsxiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#ifndef NSXIV_H
#define NSXIV_H

#if !defined(DEBUG) && !defined(NDEBUG)
#define NDEBUG
#endif

#include <stdbool.h>
#include <stddef.h>

Expand Down

0 comments on commit 4048059

Please sign in to comment.