mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 14:40:26 +01:00
util: add a wrapper for the C23 auto keyword
C23 auto is basically __auto_type so let's wrap it if our compiler doesn't provide it (yet). This lets us use `auto` as type specifier, e.g. compare enum libinput_config_status status = libinput_device_config_set(...) auto status = libinput_device_config_set(...) Note that as of now meson will never detect this as it requires -std=c23 to be passed to the compiler. This flag is only supported by Clang 18 (released 2024) and we don't want to break things for older compilers for what is a bit of a niche feature right now. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1181>
This commit is contained in:
parent
bf67c056df
commit
ecd4ea3053
2 changed files with 11 additions and 0 deletions
|
|
@ -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 <locale.h>
|
||||
void main(void) { newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue