Skip to content

Commit

Permalink
configure.ac: enable CFLAGS=-Wpedantic and fix the build
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
trofi committed Dec 9, 2024
1 parent c356ab8 commit ca50b93
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/encoder/formats.c_template
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit ca50b93

Please sign in to comment.