mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-14 03:24:50 -04:00
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:
@@ -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')
|
||||
|
||||
|
||||
|
||||
@@ -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'],
|
||||
)
|
||||
|
||||
15
tests/use-as-subproject/trivial.c
Normal file
15
tests/use-as-subproject/trivial.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user