2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

Handle warning flags better

Make --enable-werror work properly on msvc, handle extra warnings
flags for msvc in configure.ac instead of hardcoding into
make/msvc.mk, separate warnings flags into WFLAGS in autoconf.mk to
avoid duplication and to make it easier to override.
This commit is contained in:
Jay Berkenbilt 2013-01-24 11:18:28 -05:00
parent 32b62035ce
commit a11081085b
7 changed files with 55 additions and 46 deletions

View File

@ -25,6 +25,15 @@
2013-01-24 Jay Berkenbilt <ejb@ql.org>
* Make --enable-werror work for MSVC, and generally handle warning
options better for that compiler. Warning flags for that compiler
were previous hard-coded into the build with /WX enabled
unconditionally.
* Split warning flags into WFLAGS in autoconf.mk to make them
easier to override. Before they were repeated in CFLAGS and
CXXFLAGS and were commingled with other compiler flags.
* qpdf --check now does syntactic checks all pages' content
streams as well as checking overall document structure. Semantic
errors are still not checked, and there are no plans to add

View File

@ -12,12 +12,13 @@ docdir=@docdir@
htmldir=@htmldir@
pdfdir=@pdfdir
CC=@CC@
CFLAGS=@CFLAGS@
WFLAGS=@WFLAGS@
CFLAGS=@CFLAGS@ $(WFLAGS)
LDFLAGS=@LDFLAGS@
LIBS=@LIBS@
CPPFLAGS=@CPPFLAGS@
CXX=@CXX@
CXXFLAGS=@CXXFLAGS@
CXXFLAGS=@CXXFLAGS@ $(WFLAGS)
AR=@AR@
RANLIB=@RANLIB@
DLLTOOL=@DLLTOOL@

View File

@ -1,5 +1,5 @@
#!/bin/sh
./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=32 --with-buildrules=mingw
./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=32 --with-buildrules=mingw
# As of autoconf 2.69 and gcc 4.6, autoconf's configure fails to
# recognize that defining _FILE_OFFSET_BITS works with mingw32.
# Append to qpdf-config.h rather than passing CPPFLAGS on the

View File

@ -1,5 +1,5 @@
#!/bin/sh
./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=64 --with-buildrules=mingw \
./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=64 --with-buildrules=mingw \
CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++ \
LD=x86_64-w64-mingw32-ld \

View File

@ -8,4 +8,4 @@ objdump=
if test "$wordsize" = "64"; then
objdump=OBJDUMP=x86_64-w64-mingw32-objdump
fi
CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=$wordsize --with-buildrules=msvc $objdump
CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=$wordsize --with-buildrules=msvc $objdump

View File

@ -175,39 +175,48 @@ AC_ARG_WITH(buildrules,
[BUILDRULES=libtool])
AC_MSG_RESULT($BUILDRULES)
if test "$BUILDRULES" != "msvc"; then
qpdf_USE_WALL=0
AC_MSG_CHECKING(for whether $CC supports -Wall)
oCFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wall"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])],
[qpdf_USE_WALL=1],[qpdf_USE_WALL=0])
if test "$qpdf_USE_WALL" = "1"; then
AC_MSG_RESULT(yes)
CXXFLAGS="$CXXFLAGS -Wall"
else
AC_MSG_RESULT(no)
CFLAGS=$oCFLAGS
fi
AC_SUBST(WFLAGS)
qpdf_USE_EXTRA_WARNINGS=0
if test "$BUILDRULES" = "msvc"; then
dnl /w14267 makes warning 4267 a level 1 warning. This warning reports
dnl potential issues between size_t, off_t, and non-compatible integer
dnl types.
try_flags="/w14267"
else
try_flags="-Wall"
fi
AC_MSG_CHECKING(for whether $CC supports $try_flags)
oCFLAGS=$CFLAGS
CFLAGS="$CFLAGS $try_flags"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])],
[qpdf_USE_EXTRA_WARNINGS=1],[qpdf_USE_EXTRA_WARNINGS=0])
CFLAGS=$oCFLAGS
if test "$qpdf_USE_EXTRA_WARNINGS" = "1"; then
AC_MSG_RESULT(yes)
WFLAGS="$try_flags"
else
AC_MSG_RESULT(no)
fi
if test "$BUILDRULES" != "msvc"; then
AC_MSG_CHECKING(for whether to use -Werror)
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror],
[whether to use werror (default is no)]),
[if test "$enableval" = "yes"; then
qpdf_USE_WERROR=1;
else
qpdf_USE_WERROR=0;
fi], [qpdf_USE_WERROR=0])
if test "$qpdf_USE_WERROR" = "1"; then
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -Werror"
CXXFLAGS="$CXXFLAGS -Werror"
else
AC_MSG_RESULT(no)
fi
if test "$BUILDRULES" = "msvc"; then
try_flags="/WX"
else
try_flags="-Werror"
fi
AC_MSG_CHECKING(for whether to use $try_flags)
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror],
[whether to treat warnings as errors (default is no)]),
[if test "$enableval" = "yes"; then
qpdf_USE_WERROR=1;
else
qpdf_USE_WERROR=0;
fi], [qpdf_USE_WERROR=0])
if test "$qpdf_USE_WERROR" = "1"; then
AC_MSG_RESULT(yes)
WFLAGS="$WFLAGS $try_flags"
else
AC_MSG_RESULT(no)
fi
AC_SUBST(QPDF_SKIP_TEST_COMPARE_IMAGES)

View File

@ -19,16 +19,6 @@ endef
CFLAGS := $(filter-out -g,$(CFLAGS))
CXXFLAGS := $(filter-out -g,$(CXXFLAGS))
# /WX makes all warnings errors.
CFLAGS += /WX
CXXFLAGS += /WX
# /w14267 makes warning 4267 a level 1 warning. This warning reports
# potential issues between size_t, off_t, and non-compatible integer
# types.
CFLAGS += /w14267
CXXFLAGS += /w14267
clean::
$(RM) *.pdb