mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
build: Factor out some size_t checks
With Meson 0.60 (or possibly some earlier versions) we can factor the checks out as a variable can now be used as an array key. This simplifies the checks a little, while introducing no functional differences. The contents of `g_sizet_compatibility` after this block are identical with and without the changes applied. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
51c55b44ad
commit
bc51658167
44
meson.build
44
meson.build
@ -1511,52 +1511,20 @@ g_sizet_compatibility = {
|
||||
# Do separate checks for gcc/clang (and ignore other compilers for now), since
|
||||
# we need to explicitly pass -Werror to the compilers.
|
||||
# FIXME: https://github.com/mesonbuild/meson/issues/5399
|
||||
# We can’t simplify these checks using a foreach loop because dictionary keys
|
||||
# have to be string literals.
|
||||
# FIXME: https://github.com/mesonbuild/meson/issues/5231
|
||||
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||
g_sizet_compatibility += {
|
||||
'short': g_sizet_compatibility['short'] and cc.compiles(
|
||||
foreach type_name, size_compatibility : g_sizet_compatibility
|
||||
g_sizet_compatibility += { type_name: size_compatibility and
|
||||
cc.compiles(
|
||||
'''#include <stddef.h>
|
||||
size_t f (size_t *i) { return *i + 1; }
|
||||
int main (void) {
|
||||
unsigned short i = 0;
|
||||
unsigned ''' + type_name + ''' i = 0;
|
||||
f (&i);
|
||||
return 0;
|
||||
}''',
|
||||
args: ['-Werror'],
|
||||
name : 'GCC size_t typedef is short'),
|
||||
'int': g_sizet_compatibility['int'] and cc.compiles(
|
||||
'''#include <stddef.h>
|
||||
size_t f (size_t *i) { return *i + 1; }
|
||||
int main (void) {
|
||||
unsigned int i = 0;
|
||||
f (&i);
|
||||
return 0;
|
||||
}''',
|
||||
args: ['-Werror'],
|
||||
name : 'GCC size_t typedef is int'),
|
||||
'long': g_sizet_compatibility['long'] and cc.compiles(
|
||||
'''#include <stddef.h>
|
||||
size_t f (size_t *i) { return *i + 1; }
|
||||
int main (void) {
|
||||
unsigned long i = 0;
|
||||
f (&i);
|
||||
return 0;
|
||||
}''',
|
||||
args: ['-Werror'],
|
||||
name : 'GCC size_t typedef is long'),
|
||||
'long long': g_sizet_compatibility['long long'] and cc.compiles(
|
||||
'''#include <stddef.h>
|
||||
size_t f (size_t *i) { return *i + 1; }
|
||||
int main (void) {
|
||||
unsigned long long i = 0;
|
||||
f (&i);
|
||||
return 0;
|
||||
}''',
|
||||
args: ['-Werror'],
|
||||
name : 'GCC size_t typedef is long long'),
|
||||
}
|
||||
name : 'GCC size_t typedef is ' + type_name), }
|
||||
endforeach
|
||||
endif
|
||||
|
||||
if g_sizet_compatibility['short']
|
||||
|
Loading…
Reference in New Issue
Block a user