Skip to content
Snippets Groups Projects
Commit fde4b823 authored by Yang Tse's avatar Yang Tse
Browse files

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
parent b7e71a24
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ ...@@ -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,65 +787,95 @@ AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [ ...@@ -787,65 +787,95 @@ 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"
tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" #
dnl -Wcast-align is a bit too annoying on all gcc versions ;-) dnl Only gcc 1.4 or later
dnl Do not enable some warnings, when cross-compiling with a gcc if test "$compiler_num" -ge "104"; then
dnl older than 3.0, triggered on third party system headers. tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
if test "x$cross_compiling" != "xyes" || dnl If not cross-compiling with a gcc older than 3.0
test "$compiler_num" -ge "300"; then if test "x$cross_compiling" != "xyes" ||
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
fi
fi fi
#
dnl Only gcc 2.7 or later
if test "$compiler_num" -ge "207"; then if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations" 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"
fi
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 -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 Only gcc 3.0 or later
dnl Also, on gcc 4.0.X it is totally unbearable and complains all if test "$compiler_num" -ge "300"; then
dnl over making it unusable for generic purposes. Let's not use it. 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 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.
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
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" dnl gcc 1.4 or later
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
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 fi
;; ;;
......
...@@ -22,7 +22,7 @@ ...@@ -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,65 +793,95 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ ...@@ -793,65 +793,95 @@ 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"
tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" #
dnl -Wcast-align is a bit too annoying on all gcc versions ;-) dnl Only gcc 1.4 or later
dnl Do not enable some warnings, when cross-compiling with a gcc if test "$compiler_num" -ge "104"; then
dnl older than 3.0, triggered on third party system headers. tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
if test "x$cross_compiling" != "xyes" || dnl If not cross-compiling with a gcc older than 3.0
test "$compiler_num" -ge "300"; then if test "x$cross_compiling" != "xyes" ||
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
fi
fi fi
#
dnl Only gcc 2.7 or later
if test "$compiler_num" -ge "207"; then if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations" 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"
fi
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 -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 Only gcc 3.0 or later
dnl Also, on gcc 4.0.X it is totally unbearable and complains all if test "$compiler_num" -ge "300"; then
dnl over making it unusable for generic purposes. Let's not use it. 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 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.
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
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" dnl gcc 1.4 or later
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
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 fi
;; ;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment