diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-14 01:26:47 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-14 01:26:47 +0900 |
| commit | 49b139c339cd1a4cb3a8fc817a582ec6af6c3ca4 (patch) | |
| tree | bac6eda05c1a02f7df7eca4e1265cf1b896bafed | |
| parent | 6a45ad108293f9fa4f90eed55fc1101711bcc0ee (diff) | |
| download | ducc-49b139c339cd1a4cb3a8fc817a582ec6af6c3ca4.tar.gz ducc-49b139c339cd1a4cb3a8fc817a582ec6af6c3ca4.tar.zst ducc-49b139c339cd1a4cb3a8fc817a582ec6af6c3ca4.zip | |
feat: include <assert.h>
| -rw-r--r-- | include/assert.h | 16 | ||||
| -rw-r--r-- | src/preprocess.c | 1 | ||||
| -rw-r--r-- | src/std.h | 7 |
3 files changed, 17 insertions, 7 deletions
diff --git a/include/assert.h b/include/assert.h new file mode 100644 index 0000000..aac81d7 --- /dev/null +++ b/include/assert.h @@ -0,0 +1,16 @@ +#ifndef __DUCC_BUILTIN___ASSERT_H__ +#define __DUCC_BUILTIN___ASSERT_H__ + +#ifdef NDEBUG +#define assert(x) ((void)0) +#else +#define assert(x) \ + do { \ + if (!(x)) { \ + fprintf(stderr, "%s:%d: assertion failed.\n", __FILE__, __LINE__); \ + abort(); \ + } \ + } while (0) +#endif + +#endif diff --git a/src/preprocess.c b/src/preprocess.c index a32e0e5..34c2fe0 100644 --- a/src/preprocess.c +++ b/src/preprocess.c @@ -1,4 +1,5 @@ #include "preprocess.h" +#include <assert.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> @@ -6,13 +6,6 @@ // TODO: <stdlib.h> int mkstemps(char*, int); -#define assert(x) \ - do { \ - if (!(x)) { \ - fatal_error("%s:%d: assertion failed", __FILE__, __LINE__); \ - } \ - } while (0) - #define F_OK 0 #define R_OK 4 int access(const char*, int); |
