[libglnx/wip/smcv/warnings] build: Explicitly disable warnings for non-ISO C features




commit 45108f1852d329b3a4d10f6d5d3558dca8288dcb
Author: Simon McVittie <smcv collabora com>
Date:   Mon Oct 10 14:08:54 2022 +0100

    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>

 meson.build                         |  5 +++++
 tests/use-as-subproject/meson.build | 28 ++++++++++++++++++++++++++--
 tests/use-as-subproject/trivial.c   | 15 +++++++++++++++
 3 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 38ec2ea..db60533 100644
--- a/meson.build
+++ b/meson.build
@@ -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')
 
 
diff --git a/tests/use-as-subproject/meson.build b/tests/use-as-subproject/meson.build
index 2d08160..59fd736 100644
--- a/tests/use-as-subproject/meson.build
+++ b/tests/use-as-subproject/meson.build
@@ -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'],
+)
diff --git a/tests/use-as-subproject/trivial.c b/tests/use-as-subproject/trivial.c
new file mode 100644
index 0000000..4b364f1
--- /dev/null
+++ b/tests/use-as-subproject/trivial.c
@@ -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;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]