$1="-O2"
fi
fi
+
+ #
+ # -Werror forces warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
else
$2="$$2 -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
case "$host_os" in
+ darwin*)
+ #
+ # This is assumed either to be GCC or clang, both
+ # of which use -Werror to force warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
+ ;;
+
hpux*)
#
# HP C, which is what we presume we're using, doesn't
$1="$$1 -O"
;;
+ solaris*)
+ #
+ # Assumed to be Sun C, which requires -errwarn to force
+ # warnings to be treated as errors.
+ #
+ ac_lbl_cc_force_warning_errors=-errwarn
+ ;;
+
ultrix*)
AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
ac_cv___attribute__=no)])
if test "$ac_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
- V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
else
+ #
+ # We can't use __attribute__, so we can't use __attribute__((unused)),
+ # so we define _U_ to an empty string.
+ #
V_DEFS="$V_DEFS -D_U_=\"\""
fi
AC_MSG_RESULT($ac_cv___attribute__)
])
+dnl
+dnl Test whether __attribute__((unused)) can be used without warnings
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [
+AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings])
+AC_CACHE_VAL(ac_cv___attribute___unused, [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc __attribute((unused)), char **argv __attribute((unused)))
+{
+ printf("Hello, world!\n");
+ return 0;
+}
+ ]])],
+ac_cv___attribute___unused=yes,
+ac_cv___attribute___unused=no)])
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___unused" = "yes"; then
+ V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
+else
+ V_DEFS="$V_DEFS -D_U_=\"\""
+fi
+AC_MSG_RESULT($ac_cv___attribute___unused)
+])
+
+dnl
+dnl Test whether __attribute__((format)) can be used without warnings
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
+AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
+AC_CACHE_VAL(ac_cv___attribute___format, [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#include <stdlib.h>
+
+extern int foo(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ foo("%s", "test");
+}
+ ]])],
+ac_cv___attribute___format=yes,
+ac_cv___attribute___format=no)])
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___format" = "yes"; then
+ AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
+ [define if your compiler allows __attribute__((format)) without a warning])
+fi
+AC_MSG_RESULT($ac_cv___attribute___format)
+])
+
dnl
dnl Test whether __attribute__((format)) can be applied to function
dnl pointers
AC_MSG_RESULT($ac_cv___attribute___format_function_pointer)
])
+AC_DEFUN(AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER, [
+AC_MSG_CHECKING([whether __attribute__((noreturn)) can be applied to function pointers without warnings])
+AC_CACHE_VAL(ac_cv___attribute___noreturn_function_pointer, [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#include <stdlib.h>
+
+extern int (*foo)(int i)
+ __attribute__ ((noreturn));
+
+int
+main(int argc, char **argv)
+{
+ (*foo)(1);
+}
+ ]])],
+ac_cv___attribute___noreturn_function_pointer=yes,
+ac_cv___attribute___noreturn_function_pointer=no)])
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___noreturn_function_pointer" = "yes"; then
+ AC_DEFINE(__ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS, 1,
+ [define if your compiler allows __attribute__((noreturn)) to be applied to function pointers])
+fi
+AC_MSG_RESULT($ac_cv___attribute___noreturn_function_pointer)
+])
+
AC_DEFUN(AC_LBL_SSLEAY,
[
#
/* define on AIX to get certain functions */
#undef _SUN
+/* define if your compiler allows __attribute__((format)) without a warning */
+#undef __ATTRIBUTE___FORMAT_OK
+
/* define if your compiler allows __attribute__((format)) to be applied to
function pointers */
#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
+/* define if your compiler allows __attribute__((noreturn)) to be applied to
+ function pointers */
+#undef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
+
/* to handle Ultrix compilers that don't support const in prototypes */
#undef const
V_CCOPT="-O2"
fi
fi
+
+ #
+ # -Werror forces warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
else
V_INCLS="$V_INCLS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
case "$host_os" in
+ darwin*)
+ #
+ # This is assumed either to be GCC or clang, both
+ # of which use -Werror to force warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
+ ;;
+
hpux*)
#
# HP C, which is what we presume we're using, doesn't
V_CCOPT="$V_CCOPT -O"
;;
+ solaris*)
+ #
+ # Assumed to be Sun C, which requires -errwarn to force
+ # warnings to be treated as errors.
+ #
+ ac_lbl_cc_force_warning_errors=-errwarn
+ ;;
+
ultrix*)
{ echo "$as_me:$LINENO: checking that Ultrix $CC hacks const in prototypes" >&5
echo $ECHO_N "checking that Ultrix $CC hacks const in prototypes... $ECHO_C" >&6; }
#define HAVE___ATTRIBUTE__ 1
_ACEOF
- V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
else
+ #
+ # We can't use __attribute__, so we can't use __attribute__((unused)),
+ # so we define _U_ to an empty string.
+ #
V_DEFS="$V_DEFS -D_U_=\"\""
fi
{ echo "$as_me:$LINENO: result: $ac_cv___attribute__" >&5
if test "$ac_cv___attribute__" = "yes"; then
+{ echo "$as_me:$LINENO: checking whether __attribute__((unused)) can be used without warnings" >&5
+echo $ECHO_N "checking whether __attribute__((unused)) can be used without warnings... $ECHO_C" >&6; }
+if test "${ac_cv___attribute___unused+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat >conftest.$ac_ext <<_ACEOF
+
+ /* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc __attribute((unused)), char **argv __attribute((unused)))
+{
+ printf("Hello, world!\n");
+ return 0;
+}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv___attribute___unused=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv___attribute___unused=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___unused" = "yes"; then
+ V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
+else
+ V_DEFS="$V_DEFS -D_U_=\"\""
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv___attribute___unused" >&5
+echo "${ECHO_T}$ac_cv___attribute___unused" >&6; }
+
+
+{ echo "$as_me:$LINENO: checking whether __attribute__((noreturn)) can be applied to function pointers without warnings" >&5
+echo $ECHO_N "checking whether __attribute__((noreturn)) can be applied to function pointers without warnings... $ECHO_C" >&6; }
+if test "${ac_cv___attribute___noreturn_function_pointer+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat >conftest.$ac_ext <<_ACEOF
+
+ /* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+extern int (*foo)(int i)
+ __attribute__ ((noreturn));
+
+int
+main(int argc, char **argv)
+{
+ (*foo)(1);
+}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv___attribute___noreturn_function_pointer=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv___attribute___noreturn_function_pointer=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___noreturn_function_pointer" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS 1
+_ACEOF
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv___attribute___noreturn_function_pointer" >&5
+echo "${ECHO_T}$ac_cv___attribute___noreturn_function_pointer" >&6; }
+
+
+{ echo "$as_me:$LINENO: checking whether __attribute__((format)) can be used without warnings" >&5
+echo $ECHO_N "checking whether __attribute__((format)) can be used without warnings... $ECHO_C" >&6; }
+if test "${ac_cv___attribute___format+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat >conftest.$ac_ext <<_ACEOF
+
+ /* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+extern int foo(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ foo("%s", "test");
+}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv___attribute___format=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv___attribute___format=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___format" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define __ATTRIBUTE___FORMAT_OK 1
+_ACEOF
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv___attribute___format" >&5
+echo "${ECHO_T}$ac_cv___attribute___format" >&6; }
+
+ if test "$ac_cv___attribute___format" = "yes"; then
+
{ echo "$as_me:$LINENO: checking whether __attribute__((format)) can be applied to function pointers" >&5
echo $ECHO_N "checking whether __attribute__((format)) can be applied to function pointers... $ECHO_C" >&6; }
if test "${ac_cv___attribute___format_function_pointer+set}" = set; then
{ echo "$as_me:$LINENO: result: $ac_cv___attribute___format_function_pointer" >&5
echo "${ECHO_T}$ac_cv___attribute___format_function_pointer" >&6; }
+ fi
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
AC_LBL_C_INLINE
AC_C___ATTRIBUTE__
if test "$ac_cv___attribute__" = "yes"; then
- AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
+ AC_C___ATTRIBUTE___UNUSED
+ AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER
+ AC_C___ATTRIBUTE___FORMAT
+ if test "$ac_cv___attribute___format" = "yes"; then
+ AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
+ fi
fi
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
- __attribute__((format(printf, 3, 4)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf(char *, size_t, const char *, va_list)
- __attribute__((format(printf, 3, 0)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 0)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
extern const char *dnaddr_string(u_short);
extern void error(const char *, ...)
- __attribute__((noreturn, format (printf, 1, 2)));
-extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
+ __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+extern void warning(const char *, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
extern char *read_infile(char *);
extern char *copy_argv(char **);
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
- __attribute__((format(printf, 3, 4)));
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
#endif /* !defined(HAVE_SNPRINTF) */
#endif /* __osf__ */
#if !defined(HAVE_SNPRINTF)
int snprintf (char *str, size_t sz, const char *format, ...)
- __attribute__ ((format (printf, 3, 4)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
- __attribute__((format (printf, 3, 0)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 0)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
;
void (*ndo_error)(netdissect_options *,
const char *fmt, ...)
+#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
+ __attribute__ ((noreturn))
+#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
- __attribute__ ((noreturn, format (printf, 2, 3)))
-#endif
+ __attribute__ ((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
;
void (*ndo_warning)(netdissect_options *,
const char *fmt, ...)