mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 01:36:17 +01:00
build: workaround meson's cc.has_member() causing compiler warning.
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails with: ... #include <sys/stat.h> void bar(void) { struct stat foo; foo.st_mtim.tv_nsec; } ----------- Command line: `cc /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c -o /data/src/glib/build/meson-private/tmpbjjq3ikp/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1 stderr: /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c: In function 'bar': /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c:45:24: error: statement with no effect [-Werror=unused-value] 45 | foo.st_mtim.tv_nsec; | ~~~~~~~~~~~^~~~~~~~ cc1: all warnings being treated as errors ----------- Checking whether type "struct stat" has member "st_mtim.tv_nsec" : NO
This commit is contained in:
parent
8ea0f7d045
commit
90817d0fab
11
meson.build
11
meson.build
@ -518,7 +518,16 @@ foreach m : struct_members
|
||||
else
|
||||
header_check_prefix = header_check_prefix + '#include <sys/stat.h>'
|
||||
endif
|
||||
if cc.has_member('struct ' + m[0], m[1], prefix : header_check_prefix)
|
||||
# Reimplement cc.has_member() to workaround compiler warning
|
||||
# FIXME: https://github.com/mesonbuild/meson/pull/12818
|
||||
code = header_check_prefix + '''
|
||||
void bar(void) {
|
||||
struct ''' + m[0] + ''' foo;
|
||||
(void) ( foo.''' + m[1] + ''' );
|
||||
(void) foo;
|
||||
}
|
||||
'''
|
||||
if cc.compiles(code, name : 'type "struct ' + m[0] + '" has member "' + m[1] + '"')
|
||||
define = 'HAVE_STRUCT_@0@_@1@'.format(m[0].to_upper(), m[1].underscorify().to_upper())
|
||||
glib_conf.set(define, 1)
|
||||
glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
|
||||
|
Loading…
Reference in New Issue
Block a user