diff options
| author | Thomas Haller <thaller@redhat.com> | 2024-02-07 11:12:22 +0100 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-09-11 09:36:53 -0400 |
| commit | a22a50a6739160bdf93a5a11f5026112007ccf4e (patch) | |
| tree | 8d5583ca61057083fab50e08a93fd2765881fe18 /mesonbuild/compilers | |
| parent | f83dca32fe340727ada08b46d70bfc6dbba52d84 (diff) | |
| download | meson-a22a50a6739160bdf93a5a11f5026112007ccf4e.tar.gz | |
compilers: avoid -Wunused-value compiler warning in CLikeCompiler.has_members()
Otherwise, `CFLAGS='-Wall -Werror' meson build` can fail detection:
void bar(void) {
struct stat foo;
foo.st_mtim.tv_nsec;
}
-----------
Command line: `cc ./project/build/meson-private/tmpqz_gi65d/testfile.c -o ./project/build/meson-private/tmpqz_gi65d/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
stderr:
./project/build/meson-private/tmpqz_gi65d/testfile.c: In function 'bar':
./project/build/meson-private/tmpqz_gi65d/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
Diffstat (limited to 'mesonbuild/compilers')
| -rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 60a91f355..a0d6094ab 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -870,11 +870,12 @@ class CLikeCompiler(Compiler): if extra_args is None: extra_args = [] # Create code that accesses all members - members = ''.join(f'foo.{member};\n' for member in membernames) + members = ''.join(f'(void) ( foo.{member} );\n' for member in membernames) t = f'''{prefix} void bar(void) {{ {typename} foo; {members} + (void) foo; }}''' return self.compiles(t, env, extra_args=extra_args, dependencies=dependencies) |
