make debug assertions opt-in
This commit is contained in:
parent
986d816b43
commit
5acd671462
14
readarg.h
14
readarg.h
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define READARG_STRINGS(...) ((char *[]){__VA_ARGS__, NULL})
|
#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_IMPLEMENTATION
|
||||||
|
|
||||||
|
#ifdef READARG_DEBUG
|
||||||
|
#pragma push_macro("NDEBUG")
|
||||||
|
#undef NDEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -393,7 +398,8 @@ static void readarg_assign_opers(struct readarg_parser *rp)
|
||||||
size_t req;
|
size_t req;
|
||||||
} rest = {
|
} rest = {
|
||||||
count - nlower,
|
count - nlower,
|
||||||
nlower};
|
nlower,
|
||||||
|
};
|
||||||
|
|
||||||
for (size_t i = 0; readarg_validate_arg(rp->opers + i); i++)
|
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];
|
: bounds.val[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef READARG_DEBUG
|
||||||
|
#pragma pop_macro("NDEBUG")
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#define READARG_IMPLEMENTATION
|
#define READARG_IMPLEMENTATION
|
||||||
|
#define READARG_DEBUG
|
||||||
|
|
||||||
#include "../readarg.h"
|
#include "../readarg.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct readarg_opt opts[] = {
|
struct readarg_opt opts[] = {
|
||||||
|
|
Loading…
Reference in a new issue