From ca50b9326087556e82810fa2f01cd3394daad95c Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Mon, 9 Dec 2024 17:03:07 +0000 Subject: [PATCH] configure.ac: enable `CFLAGS=-Wpedantic` and fix the build `meson` enables `-Wpedantic` option for some cases of warning levels. Unfortunataly it not only enables warnings but also rejects otherwise valid code to be accepted as: CC encoder/formats.gen.o encoder/formats.gen.c:29:14: error: array size missing in 'formatName' 29 | static char *formatName[]; | ^~~~~~~~~~ encoder/formats.gen.c:44:14: error: conflicting types for 'formatName'; have 'char *[119]' 44 | static char *formatName[NUM_FORMATS+1] = { | ^~~~~~~~~~ encoder/formats.gen.c:29:14: note: previous declaration of 'formatName' with type 'char *[1]' 29 | static char *formatName[]; | ^~~~~~~~~~ encoder/formats.gen.c:44:14: warning: 'formatName' defined but not used [-Wunused-variable] 44 | static char *formatName[NUM_FORMATS+1] = { | ^~~~~~~~~~ The change fixes the inconsistency between the declaration and the definition. --- configure.ac | 2 ++ src/encoder/formats.c_template | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 49e37e2..45c7f3d 100644 --- a/configure.ac +++ b/configure.ac @@ -179,6 +179,8 @@ AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration], [CFLAGS="$CFLAGS AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"], [], [-Werror]) AX_CHECK_COMPILE_FLAG([-Wunused-function], [CFLAGS="$CFLAGS -Wunused-function"], [], [-Werror]) AX_CHECK_COMPILE_FLAG([-Wunused-variable], [CFLAGS="$CFLAGS -Wunused-variable"], [], [-Werror]) +# Useful to catch non-standard constructs. +AX_CHECK_COMPILE_FLAG([-Wpedantic], [CFLAGS="$CFLAGS -Wpedantic"], [], [-Werror]) dnl Treat warnings as errors AC_ARG_ENABLE([werror], diff --git a/src/encoder/formats.c_template b/src/encoder/formats.c_template index 8ffdc79..6e7700f 100644 --- a/src/encoder/formats.c_template +++ b/src/encoder/formats.c_template @@ -22,7 +22,7 @@ #include "encoder/encoder.h" #include "encoder/EMInst.h" -static char *formatName[]; +static char *formatName[NUM_FORMATS+1]; char *instFormatName(InstID instID) {