#ifndef CONTS_H #define CONTS_H #define CONTS_JOIN2(a, b) a##_##b #define CONTS_JOIN(a, b) CONTS_JOIN2(a, b) #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 (CONTS_AUTO i = CONTS_JOIN(name, begin)(s);\ !CONTS_JOIN(name, end)(s, i);\ i = CONTS_JOIN(name, next)(i)) #endif /* CONTS_H */