From f21efc9bd4ac4fd104883280ad9f3eae14a95b22 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 29 Sep 2020 09:01:54 +0200 Subject: added c_withfile (f, open) macro. --- stc/cdefs.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stc/cdefs.h b/stc/cdefs.h index 3a246372..1dcfeaef 100644 --- a/stc/cdefs.h +++ b/stc/cdefs.h @@ -29,18 +29,18 @@ #include #if defined(_MSC_VER) - #define STC_FORCE_INLINE static __forceinline +# define STC_FORCE_INLINE static __forceinline #elif defined(__GNUC__) || defined(__clang__) - #define STC_FORCE_INLINE static inline __attribute((always_inline)) +# define STC_FORCE_INLINE static inline __attribute((always_inline)) #else - #define STC_FORCE_INLINE static inline +# define STC_FORCE_INLINE static inline #endif #define STC_INLINE static inline #if defined(STC_HEADER) || defined(STC_IMPLEMENTATION) - #define STC_API extern +# define STC_API extern #else - #define STC_API STC_INLINE +# define STC_API STC_INLINE #endif enum {_c_max_buffer = 512}; @@ -92,6 +92,8 @@ enum {_c_max_buffer = 512}; #define c_forrange_5(i, type, start, stop, step) \ for (type i=start, i##_inc_=step, i##_end_=(stop) - (0 < i##_inc_); (i <= i##_end_) == (0 < i##_inc_); i += i##_inc_) +#define c_withfile(f, open) for (FILE *f = open; f; fclose(f), f = NULL) + #define c_push_items(self, ctype, ...) do { \ const ctype##_input_t __arr[] = __VA_ARGS__; \ ctype##_push_n(self, __arr, sizeof(__arr)/sizeof(__arr[0])); \ -- cgit v1.2.3