make debug assertions opt-in

This commit is contained in:
Lukas Wurzinger 2022-10-31 16:48:59 +01:00
parent 986d816b43
commit 5acd671462
2 changed files with 15 additions and 2 deletions

View file

@ -1,6 +1,6 @@
#pragma once
#include <stdio.h>
#include <stddef.h>
#define READARG_STRINGS(...) ((char *[]){__VA_ARGS__, NULL})
@ -91,6 +91,11 @@ size_t readarg_select_lower(struct readarg_bounds bounds);
#ifdef READARG_IMPLEMENTATION
#ifdef READARG_DEBUG
#pragma push_macro("NDEBUG")
#undef NDEBUG
#endif
#include <assert.h>
#include <string.h>
@ -393,7 +398,8 @@ static void readarg_assign_opers(struct readarg_parser *rp)
size_t req;
} rest = {
count - nlower,
nlower};
nlower,
};
for (size_t i = 0; readarg_validate_arg(rp->opers + i); i++)
{
@ -530,4 +536,8 @@ size_t readarg_select_lower(struct readarg_bounds bounds)
: bounds.val[1];
}
#ifdef READARG_DEBUG
#pragma pop_macro("NDEBUG")
#endif
#endif

View file

@ -1,7 +1,10 @@
#define READARG_IMPLEMENTATION
#define READARG_DEBUG
#include "../readarg.h"
#include <stdio.h>
int main(int argc, char **argv)
{
struct readarg_opt opts[] = {