From 5f832714d383497618a9305a70d47a0da0922c6c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 18 Jan 2024 09:07:55 +0100 Subject: Simplify code using libcompat --- src/compat.h | 26 ++++++++++++++++++++++++++ src/grab.c | 6 +----- 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 src/compat.h (limited to 'src') diff --git a/src/compat.h b/src/compat.h new file mode 100644 index 0000000..fedea6a --- /dev/null +++ b/src/compat.h @@ -0,0 +1,26 @@ +/* This compatibility header was generated by the libcompat gen script. + You can find it over at https://git.sr.ht/~mango/libcompat. */ + +#ifndef LIBCOMPAT_COMPAT_H +#define LIBCOMPAT_COMPAT_H + +#if __STDC_VERSION__ >= 202311L +# define LIBCOMPAT_IS_23 1 +#endif + +#if !LIBCOMPAT_IS_23 +# include +#endif + +#if !LIBCOMPAT_IS_23 +# ifndef NULL +# include +# endif +# define nullptr NULL +#endif + +#if !LIBCOMPAT_IS_23 +# define static_assert(e, ...) _Static_assert(e, ""__VA_ARGS__) +#endif + +#endif /* !LIBCOMPAT_COMPAT_H */ diff --git a/src/grab.c b/src/grab.c index 8df2684..b005c4a 100644 --- a/src/grab.c +++ b/src/grab.c @@ -7,11 +7,6 @@ #include #include #include -#if !GRAB_IS_C23 -# include -# include -# define nullptr NULL -#endif #if GRAB_DO_PCRE # include @@ -22,6 +17,7 @@ # endif #endif +#include "compat.h" #include "da.h" #define die(...) err(EXIT_FAILURE, __VA_ARGS__); -- cgit v1.2.3