[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix AC_CHECK_DECL
From: |
Ralf Wildenhues |
Subject: |
Fix AC_CHECK_DECL |
Date: |
Tue, 26 Sep 2006 20:14:06 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
AC_CHECK_DECL currently does not work with compilers in picky mode
(-Wall -Werror, for example), and also it does not work at all with
struct objects for example.
The following patch tries to fix that. I think there could be issues on
systems where pointers to data and pointers to functions are incompatible,
but I don't know a good quick way around that. Do you think we may need
to, in case the cast to `char *' failed, try another compilation with a
cast to some function pointer? I think it would probably suffice to
wait for a bug report (the testsuite addition should expose this).
So, OK to apply?
Cheers,
Ralf
* lib/autoconf/general.m4 (AC_CHECK_DECL): Fix test for struct
objects by taking the address of the symbol; this also avoids
warnings for other usage cases with a picky compiler.
* tests/semantics.at (AC_CHECK_DECLS): Also check macros,
structure, and function symbols.
* NEWS: Update.
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.401
diff -u -r1.401 NEWS
--- NEWS 26 Sep 2006 06:04:35 -0000 1.401
+++ NEWS 26 Sep 2006 18:10:55 -0000
@@ -13,6 +13,8 @@
New macro, with the behavior of the 2.60a AC_COMPUTE_INT macro.
AC_COMPUTE_INT no longer caches or reports results.
+** AC_CHECK_DECL now also works with structure objects.
+
** GNU M4 1.4.7 or later is now recommended.
* Major changes in Autoconf 2.60a (2006-08-25)
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.930
diff -u -r1.930 general.m4
--- lib/autoconf/general.m4 14 Sep 2006 09:40:59 -0000 1.930
+++ lib/autoconf/general.m4 26 Sep 2006 18:10:56 -0000
@@ -2546,7 +2546,7 @@
AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
[#ifndef $1
- char *p = (char *) $1;
+ char *p = (char *) & $1;
return !p;
#endif
])],
Index: tests/semantics.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/semantics.at,v
retrieving revision 1.57
diff -u -r1.57 semantics.at
--- tests/semantics.at 26 Sep 2006 18:07:16 -0000 1.57
+++ tests/semantics.at 26 Sep 2006 18:10:56 -0000
@@ -106,10 +106,18 @@
# Check that it performs the correct actions:
# Must define NEED_NO_DECL, but not NEED_YES_DECL.
AT_CHECK_MACRO([AC_CHECK_DECLS],
-[[AC_CHECK_DECLS([yes, no],,,
- [int yes = 1;])]],
+[[AC_CHECK_DECLS([yes, no, mystruct, myfunc, mymacro1, mymacro2],,,
+ [[int yes = 1;
+ struct { int x[20]; } mystruct;
+ extern int myfunc();
+ #define mymacro1(arg) arg
+ #define mymacro2]])]],
[AT_CHECK_DEFINES(
-[#define HAVE_DECL_NO 0
+[#define HAVE_DECL_MYFUNC 1
+#define HAVE_DECL_MYMACRO1 1
+#define HAVE_DECL_MYMACRO2 1
+#define HAVE_DECL_MYSTRUCT 1
+#define HAVE_DECL_NO 0
#define HAVE_DECL_YES 1
])])
- Fix AC_CHECK_DECL,
Ralf Wildenhues <=