build: Explicitly disable warnings for non-ISO C features

libglnx is intentionally not portable to non-Unix platforms or to
compilers that do not implement gcc/clang extensions, so it's
counterproductive to warn about these extensions, even if libglnx is used
by a parent project that generally (for the parts that don't use
libglnx) wants to be portable to any ISO C compiler.

Suggested by Will Thompson on !36.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2022-10-10 14:08:54 +01:00
parent f780507d5b
commit 45108f1852
3 changed files with 46 additions and 2 deletions

View File

@@ -14,6 +14,11 @@ project(
add_project_arguments('-D_GNU_SOURCE', language: 'c')
add_project_arguments('-Wno-unused-local-typedefs', language: 'c')
# We are intentionally using non-ISO features in this (sub)project,
# even if a parent project wants to use pedantic warnings
add_project_arguments('-Wno-pedantic', language: 'c')
add_project_arguments('-Wno-variadic-macros', language: 'c')
cc = meson.get_compiler('c')

View File

@@ -4,6 +4,10 @@
project(
'use-libglnx-as-subproject',
'c',
default_options : [
'c_std=gnu99',
'warning_level=3',
],
version : '0',
meson_version : '>=0.49.0',
)
@@ -20,5 +24,25 @@ libglnx = subproject('libglnx')
libglnx_dep = libglnx.get_variable('libglnx_dep')
libglnx_testlib_dep = libglnx.get_variable('libglnx_testlib_dep')
executable('use-libglnx', 'use-libglnx.c', dependencies : [libglnx_dep, glib_dep])
executable('use-testlib', 'use-testlib.c', dependencies : [libglnx_testlib_dep, glib_dep])
# This executable is compiled at warning_level=3 by default
executable(
'trivial',
'trivial.c',
dependencies : [glib_dep],
)
# These can't be compiled at warning_level=3 because they use non-ISO
# compiler features in the libglnx headers, which would be warnings or
# errors with -Wpedantic
executable(
'use-libglnx',
'use-libglnx.c',
dependencies : [libglnx_dep, glib_dep],
override_options : ['warning_level=2'],
)
executable(
'use-testlib',
'use-testlib.c',
dependencies : [libglnx_testlib_dep, glib_dep],
override_options : ['warning_level=2'],
)

View File

@@ -0,0 +1,15 @@
/*
* Copyright 2022 Collabora Ltd.
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <glib.h>
int
main (void)
{
GError *error = NULL;
g_clear_error (&error);
return 0;
}