Skip to content

Commit ca50b93

Browse files
committed
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.
1 parent c356ab8 commit ca50b93

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

configure.ac

+2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration], [CFLAGS="$CFLAGS
179179
AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"], [], [-Werror])
180180
AX_CHECK_COMPILE_FLAG([-Wunused-function], [CFLAGS="$CFLAGS -Wunused-function"], [], [-Werror])
181181
AX_CHECK_COMPILE_FLAG([-Wunused-variable], [CFLAGS="$CFLAGS -Wunused-variable"], [], [-Werror])
182+
# Useful to catch non-standard constructs.
183+
AX_CHECK_COMPILE_FLAG([-Wpedantic], [CFLAGS="$CFLAGS -Wpedantic"], [], [-Werror])
182184

183185
dnl Treat warnings as errors
184186
AC_ARG_ENABLE([werror],

src/encoder/formats.c_template

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "encoder/encoder.h"
2323
#include "encoder/EMInst.h"
2424

25-
static char *formatName[];
25+
static char *formatName[NUM_FORMATS+1];
2626

2727
char *instFormatName(InstID instID)
2828
{

0 commit comments

Comments
 (0)