[glib/wip/pwithnall/meson-cleanups: 3/3] build: Factor out some size_t checks
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pwithnall/meson-cleanups: 3/3] build: Factor out some size_t checks
- Date: Thu, 12 May 2022 10:21:21 +0000 (UTC)
commit 3f9ed4acb6d68a013da08120b865617645e0d04a
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu May 12 11:19:15 2022 +0100
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>
meson.build | 44 ++++++--------------------------------------
1 file changed, 6 insertions(+), 38 deletions(-)
---
diff --git a/meson.build b/meson.build
index cfa702658e..a82df7a8c0 100644
--- a/meson.build
+++ b/meson.build
@@ -1508,52 +1508,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']
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]