summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/al/lib.h8
-rw-r--r--meson.build10
-rw-r--r--meson_options.txt1
-rwxr-xr-xscripts/line_count.sh2
4 files changed, 17 insertions, 4 deletions
diff --git a/include/al/lib.h b/include/al/lib.h
index 73861a8..5e65149 100644
--- a/include/al/lib.h
+++ b/include/al/lib.h
@@ -43,7 +43,13 @@
#include <wchar.h>
#include <stdio.h>
#include <stdarg.h>
+#if !defined AL_DEBUG && defined AL_RELEASE_ASSERTS
+#undef NDEBUG
#include <assert.h>
+#define NDEBUG
+#else
+#include <assert.h>
+#endif
#include <ctype.h>
#ifdef AL_MEMORY_TRACKING
@@ -94,7 +100,7 @@ static inline void *al_realloc(void *ptr, size_t n) { return ptr ? realloc(ptr,
#define al_snprintf snprintf
#define al_vsnprintf vsnprintf
#define al_fflush fflush
-#ifdef AL_DEBUG
+#if defined AL_DEBUG || defined AL_RELEASE_ASSERTS
#define al_assert assert
#else
#define al_assert(expr) do { (void)sizeof(expr); } while (0) // NOLINT(bugprone-sizeof-expression)
diff --git a/meson.build b/meson.build
index 2c20b45..849aec6 100644
--- a/meson.build
+++ b/meson.build
@@ -24,8 +24,14 @@ have_wide_string_width = compiler.has_function('wcswidth')
# For testing: '-Wshadow', '-Wconversion', '-Wc++-compat'
alabaster_args = ['-fstrict-aliasing', '-Wstrict-aliasing']
+if get_option('release-asserts')
+ alabaster_args += ['-DAL_RELEASE_ASSERTS']
+endif
+
if is_debug
alabaster_args += ['-DAL_DEBUG']
+else
+ alabaster_args += ['-DNDEBUG']
endif
if is_msvc_specifically
@@ -58,8 +64,8 @@ alabaster_src = [
'src/lib.c',
'src/random.c',
'src/str.c',
- 'src/log.c',
- 'src/ring_buffer.c'
+ 'src/ring_buffer.c',
+ 'src/log.c'
]
alabaster_inc = include_directories('include')
alabaster_deps = [c89atomic]
diff --git a/meson_options.txt b/meson_options.txt
index 14a2c36..7f05e0a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1 +1,2 @@
+option('release-asserts', type: 'boolean', value: false, yield: true)
option('tests', type: 'feature', value: 'auto', yield: true)
diff --git a/scripts/line_count.sh b/scripts/line_count.sh
index 6af0fe0..a6ac787 100755
--- a/scripts/line_count.sh
+++ b/scripts/line_count.sh
@@ -1,3 +1,3 @@
#! /usr/bin/env sh
export LC_ALL="C"
-find ./src ./include -type f -exec loccount {} +
+find ./src ./include -type f -exec sloccount {} +