Adjust GCC warnings:

Better disable following warnings when cross-compiling with a gcc older
  than 3.0, to avoid warnings from third party system headers:

    -Wmissing-declarations
    -Wmissing-prototypes
    -Wunused
    -Wshadow
This commit is contained in:
Yang Tse
2008-10-14 14:19:34 +00:00
parent b7e71a249e
commit fde4b823f1
2 changed files with 122 additions and 62 deletions

View File

@@ -16,7 +16,7 @@
#*************************************************************************** #***************************************************************************
# File version for 'aclocal' use. Keep it a single number. # File version for 'aclocal' use. Keep it a single number.
# serial 29 # serial 32
dnl CARES_CHECK_COMPILER dnl CARES_CHECK_COMPILER
@@ -787,66 +787,96 @@ AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [
GNU_C) GNU_C)
# #
if test "$want_warnings" = "yes"; then if test "$want_warnings" = "yes"; then
#
dnl Do not enable -pedantic when cross-compiling with a gcc older dnl Do not enable -pedantic when cross-compiling with a gcc older
dnl than 3.0, to avoid warnings from third party system headers. dnl than 3.0, to avoid warnings from third party system headers.
if test "x$cross_compiling" != "xyes" || if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -pedantic" tmp_CFLAGS="$tmp_CFLAGS -pedantic"
fi fi
#
dnl Set of options we believe *ALL* gcc versions support: dnl Set of options we believe *ALL* gcc versions support:
tmp_CFLAGS="$tmp_CFLAGS -Wall -W -Winline -Wnested-externs" tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
#
dnl Only gcc 1.4 or later
if test "$compiler_num" -ge "104"; then
tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
dnl -Wcast-align is a bit too annoying on all gcc versions ;-) dnl If not cross-compiling with a gcc older than 3.0
dnl Do not enable some warnings, when cross-compiling with a gcc
dnl older than 3.0, triggered on third party system headers.
if test "x$cross_compiling" != "xyes" || if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
fi
fi
#
dnl Only gcc 2.7 or later
if test "$compiler_num" -ge "207"; then
tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
dnl If not cross-compiling with a gcc older than 3.0
if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
fi fi
if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
fi fi
if test "$compiler_num" -gt "295"; then #
dnl only if the compiler is newer than 2.95 since we got lots of dnl Only gcc 2.95 or later
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with if test "$compiler_num" -ge "295"; then
dnl gcc 2.95.4 on FreeBSD 4.9! tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long -Wno-multichar -Wshadow"
tmp_CFLAGS="$tmp_CFLAGS -Wsign-compare -Wundef"
fi fi
#
dnl Only gcc 2.96 or later
if test "$compiler_num" -ge "296"; then if test "$compiler_num" -ge "296"; then
dnl gcc 2.96 or later
tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal" tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
dnl -Wundef used only if gcc is 2.96 or later since we get
dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
dnl headers with gcc 2.95.4 on FreeBSD 4.9
tmp_CFLAGS="$tmp_CFLAGS -Wundef"
fi fi
if test "$compiler_num" -gt "296"; then #
dnl this option does not exist in 2.96 dnl Only gcc 2.97 or later
if test "$compiler_num" -ge "297"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
fi fi
#
dnl Only gcc 3.0 or later
if test "$compiler_num" -ge "300"; then
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
dnl on i686-Linux as it gives us heaps with false positives. dnl on i686-Linux as it gives us heaps with false positives.
dnl Also, on gcc 4.0.X it is totally unbearable and complains all dnl Also, on gcc 4.0.X it is totally unbearable and complains all
dnl over making it unusable for generic purposes. Let's not use it. dnl over making it unusable for generic purposes. Let's not use it.
tmp_CFLAGS="$tmp_CFLAGS"
fi
#
dnl Only gcc 3.3 or later
if test "$compiler_num" -ge "303"; then if test "$compiler_num" -ge "303"; then
dnl gcc 3.3 and later
tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes" tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
fi fi
#
dnl Only gcc 3.4 or later
if test "$compiler_num" -ge "304"; then if test "$compiler_num" -ge "304"; then
dnl gcc 3.4 and later
tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
fi fi
#
fi fi
# #
dnl Do not issue warnings for code in system include paths. dnl Do not issue warnings for code in system include paths.
if test "$compiler_num" -ge "300"; then if test "$compiler_num" -ge "300"; then
dnl gcc 3.0 and later
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
else else
dnl Disable some warnings, when cross-compiling with a gcc dnl When cross-compiling with a gcc older than 3.0, disable
dnl older than 3.0, triggered on third party system headers. dnl some warnings triggered on third party system headers.
if test "x$cross_compiling" = "xyes"; then if test "x$cross_compiling" = "xyes"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes" if test "$compiler_num" -ge "104"; then
dnl gcc 1.4 or later
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
fi fi
if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
fi
fi
fi fi
;; ;;
# #

View File

@@ -22,7 +22,7 @@
#*************************************************************************** #***************************************************************************
# File version for 'aclocal' use. Keep it a single number. # File version for 'aclocal' use. Keep it a single number.
# serial 28 # serial 31
dnl CURL_CHECK_COMPILER dnl CURL_CHECK_COMPILER
@@ -793,66 +793,96 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
GNU_C) GNU_C)
# #
if test "$want_warnings" = "yes"; then if test "$want_warnings" = "yes"; then
#
dnl Do not enable -pedantic when cross-compiling with a gcc older dnl Do not enable -pedantic when cross-compiling with a gcc older
dnl than 3.0, to avoid warnings from third party system headers. dnl than 3.0, to avoid warnings from third party system headers.
if test "x$cross_compiling" != "xyes" || if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -pedantic" tmp_CFLAGS="$tmp_CFLAGS -pedantic"
fi fi
#
dnl Set of options we believe *ALL* gcc versions support: dnl Set of options we believe *ALL* gcc versions support:
tmp_CFLAGS="$tmp_CFLAGS -Wall -W -Winline -Wnested-externs" tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
#
dnl Only gcc 1.4 or later
if test "$compiler_num" -ge "104"; then
tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
dnl -Wcast-align is a bit too annoying on all gcc versions ;-) dnl If not cross-compiling with a gcc older than 3.0
dnl Do not enable some warnings, when cross-compiling with a gcc
dnl older than 3.0, triggered on third party system headers.
if test "x$cross_compiling" != "xyes" || if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
fi
fi
#
dnl Only gcc 2.7 or later
if test "$compiler_num" -ge "207"; then
tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
dnl If not cross-compiling with a gcc older than 3.0
if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
fi fi
if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
fi fi
if test "$compiler_num" -gt "295"; then #
dnl only if the compiler is newer than 2.95 since we got lots of dnl Only gcc 2.95 or later
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with if test "$compiler_num" -ge "295"; then
dnl gcc 2.95.4 on FreeBSD 4.9! tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long -Wno-multichar -Wshadow"
tmp_CFLAGS="$tmp_CFLAGS -Wsign-compare -Wundef"
fi fi
#
dnl Only gcc 2.96 or later
if test "$compiler_num" -ge "296"; then if test "$compiler_num" -ge "296"; then
dnl gcc 2.96 or later
tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal" tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
dnl -Wundef used only if gcc is 2.96 or later since we get
dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
dnl headers with gcc 2.95.4 on FreeBSD 4.9
tmp_CFLAGS="$tmp_CFLAGS -Wundef"
fi fi
if test "$compiler_num" -gt "296"; then #
dnl this option does not exist in 2.96 dnl Only gcc 2.97 or later
if test "$compiler_num" -ge "297"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
fi fi
#
dnl Only gcc 3.0 or later
if test "$compiler_num" -ge "300"; then
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
dnl on i686-Linux as it gives us heaps with false positives. dnl on i686-Linux as it gives us heaps with false positives.
dnl Also, on gcc 4.0.X it is totally unbearable and complains all dnl Also, on gcc 4.0.X it is totally unbearable and complains all
dnl over making it unusable for generic purposes. Let's not use it. dnl over making it unusable for generic purposes. Let's not use it.
tmp_CFLAGS="$tmp_CFLAGS"
fi
#
dnl Only gcc 3.3 or later
if test "$compiler_num" -ge "303"; then if test "$compiler_num" -ge "303"; then
dnl gcc 3.3 and later
tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes" tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
fi fi
#
dnl Only gcc 3.4 or later
if test "$compiler_num" -ge "304"; then if test "$compiler_num" -ge "304"; then
dnl gcc 3.4 and later
tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
fi fi
#
fi fi
# #
dnl Do not issue warnings for code in system include paths. dnl Do not issue warnings for code in system include paths.
if test "$compiler_num" -ge "300"; then if test "$compiler_num" -ge "300"; then
dnl gcc 3.0 and later
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
else else
dnl Disable some warnings, when cross-compiling with a gcc dnl When cross-compiling with a gcc older than 3.0, disable
dnl older than 3.0, triggered on third party system headers. dnl some warnings triggered on third party system headers.
if test "x$cross_compiling" = "xyes"; then if test "x$cross_compiling" = "xyes"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes" if test "$compiler_num" -ge "104"; then
dnl gcc 1.4 or later
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
fi fi
if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
fi
fi
fi fi
;; ;;
# #