diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | include/conts/conts.h | 10 |
2 files changed, 10 insertions, 2 deletions
@@ -1,4 +1,4 @@ -CFLAGS = -g -std=c23 -Wall -Wextra +CFLAGS = -g -Wall -Wextra check: check-vec check-sptree check-map check-vec: diff --git a/include/conts/conts.h b/include/conts/conts.h index 862bd31..d175d30 100644 --- a/include/conts/conts.h +++ b/include/conts/conts.h @@ -7,8 +7,16 @@ #define CONTAINER_OF(ptr, type, member) \ (type *)((char *)(ptr) - offsetof(type, member)) +#if __STDC_VERSION__ >= 202311UL +# define CONTS_AUTO auto +#elif defined(__GNUC__) +# define CONTS_AUTO __auto_type +#else +# warning "iteration won't work with this compiler" +#endif + #define foreach(name, i, s)\ - for (auto i = CONTS_JOIN(name, begin)(s);\ + for (CONTS_AUTO i = CONTS_JOIN(name, begin)(s);\ !CONTS_JOIN(name, end)(s, i);\ i = CONTS_JOIN(name, next)(i)) #endif /* CONTS_H */ |