summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-29 09:01:54 +0200
committerTyge Løvset <[email protected]>2020-09-29 09:01:54 +0200
commitf21efc9bd4ac4fd104883280ad9f3eae14a95b22 (patch)
tree3cb6fdb5d6dc41751dc8ddf0d736484b8f1f2a67
parent40f41d2d717431023c8b835ac48bd6b90e630aa5 (diff)
downloadSTC-modified-f21efc9bd4ac4fd104883280ad9f3eae14a95b22.tar.gz
STC-modified-f21efc9bd4ac4fd104883280ad9f3eae14a95b22.zip
added c_withfile (f, open) macro.
-rw-r--r--stc/cdefs.h12
1 files 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 <assert.h>
#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])); \