[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Eliminating warnings in tests

From: Pavel Roskin
Subject: Eliminating warnings in tests
Date: Wed, 13 Jun 2001 16:25:35 -0400 (EDT)


Some people (myself included) may want to use -Werror to disallow any
warnings in the project. I understand that it's now recommended to give
configure the same CFLAGS that will be used instead of overriding them on
the make command line.

That's why it's important to get rid of the warnings that may be caused by
the autoconf tests. I haven't made a complete scan yet, but this patch
fixes three warnings I have encountered first.

I believe that Autoconf should be warning free with the latest gcc when
-Wall is used. "-W -ansi -pedantic" would probably be an overkill - it's
IMO unwise to use those options with -Werror on non-trivial projects.

I also replaced `foo' with `ac_aggr' for consistency in AC_CHECK_MEMBER.

        * acheaders.m4 (_AC_CHECK_HEADER_DIRENT): Instead of defining
        an unused pointer use cast to this type and `if' statement to
        avoid warnings from the compiler.
        (AC_HEADER_TIME): Likewise.
        * actypes.m4 (AC_CHECK_MEMBER): s/foo/ac_aggr/. Use the member
        in `if' statement to avoid warnings from the compiler. Declare
        ac_aggr static to avoid the need to initialize it.

Pavel Roskin

--- acheaders.m4
+++ acheaders.m4
@@ -119,7 +119,8 @@
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
 #include <$1>
-                                    [DIR *dirp = 0;])],
+                                    [if ((DIR *) 0)
+return 0;])],
                    [AS_VAR_SET(ac_Header, yes)],
                    [AS_VAR_SET(ac_Header, no)])])
 AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
@@ -310,7 +311,8 @@
 #include <sys/time.h>
 #include <time.h>
-[struct tm *tp;])],
+[if ((struct tm *) 0)
+return 0;])],
 if test $ac_cv_header_time = yes; then
--- actypes.m4
+++ actypes.m4
@@ -423,10 +423,11 @@
 dnl Extract the aggregate name, and the member name
 AC_CACHE_CHECK([for $1], ac_Member,
-[dnl AGGREGATE foo;
-m4_patsubst([$1], [\..*]) foo;
-dnl foo.MEMBER;
-foo.m4_patsubst([$1], [^[^.]*\.]);])],
+[dnl AGGREGATE ac_aggr;
+static m4_patsubst([$1], [\..*]) ac_aggr;
+dnl ac_aggr.MEMBER;
+if (ac_aggr.m4_patsubst([$1], [^[^.]*\.]))
+return 0;])],
                 [AS_VAR_SET(ac_Member, yes)],
                 [AS_VAR_SET(ac_Member, no)])])
 AS_IF([test AS_VAR_GET(ac_Member) = yes], [$2], [$3])dnl

reply via email to

[Prev in Thread] Current Thread [Next in Thread]