diff --git a/meson.build b/meson.build index 4ab047f..cccab65 100644 --- a/meson.build +++ b/meson.build @@ -74,6 +74,15 @@ if cc.has_function('memfd_create', prefix: '#define _GNU_SOURCE\n#include + +void func() { auto foo = gmtime(NULL); foo->tm_sec = 0; } +''' +if cc.compiles(code, name: 'has C23 auto keyword') + config_h.set('HAVE_C23_AUTO', '1') +endif + dep_math = cc.find_library('m', required: false) dep_epoll = dependency('epoll-shim', required: false) dep_libxkbcommon = dependency('xkbcommon', required: false) diff --git a/src/util-macros.h b/src/util-macros.h index f3ee5b1..369ca58 100644 --- a/src/util-macros.h +++ b/src/util-macros.h @@ -31,6 +31,10 @@ #include #include +#ifndef HAVE_C23_AUTO +#define auto __auto_type +#endif + #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) #define ARRAY_FOR_EACH(_arr, _elem) \ for (size_t _i = 0; _i < ARRAY_LENGTH(_arr) && (_elem = &_arr[_i]); _i++)