diff --git a/meson.build b/meson.build index 0c7d6300..68fb91ee 100644 --- a/meson.build +++ b/meson.build @@ -133,6 +133,13 @@ if cc.has_header('xlocale.h') config_h.set('HAVE_XLOCALE_H', '1') endif +code = ''' +void func() { auto foo = "test"; } +''' +if cc.compiles(code, name: 'has C23 auto keyword') + config_h.set('HAVE_C23_AUTO', '1') +endif + code = ''' #include void main(void) { newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); } diff --git a/src/util-macros.h b/src/util-macros.h index 29a34f6a..4fb78dc3 100644 --- a/src/util-macros.h +++ b/src/util-macros.h @@ -27,6 +27,10 @@ #include "config.h" +#ifndef HAVE_C23_AUTO +#define auto __auto_type +#endif + #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) /** * Iterate through the array _arr, assigning the variable elem to each