+2010-06-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ Documentation and tests for the AC_CHECK_DECL change.
+ * lib/autoconf/general.m4 (_AC_CHECK_DECL_BODY): Squash trailing
+ spaces in as_decl_name.
+ (_AC_CHECK_DECLS): Likewise for the define.
+ * tests/semantics.at (AC_CHECK_DECLS): Extend test.
+ * doc/autoconf.texi (Generic Declarations): Update.
+ * NEWS: Update.
+
2010-06-01 Joern Rennecke <joern.rennecke@embecosm.com> (tiny change)
Generalize AC_CHECK_DECL for C++: allow optional arguments.
** Autoconf should work on EBCDIC hosts.
+** AC_CHECK_DECL and AC_CHECK_DECLS accept optional function argument types
+ for overloaded C++ functions.
+
* Major changes in Autoconf 2.65 (2009-11-21) [stable]
Released by Eric Blake, based on git versions 2.64.*.
This macro actually tests whether @var{symbol} is defined as a macro or
can be used as an r-value, not whether it is really declared, because it
-is much safer to avoid
-introducing extra declarations when they are not needed.
+is much safer to avoid introducing extra declarations when they are not
+needed. In order to facilitate use of C++ and overloaded function
+declarations, it is possible to specify function argument types in
+parentheses for types which can be zero-initialized:
+
+@example
+AC_CHECK_DECL([basename(char *)])
+@end example
This macro caches its result in the @code{ac_cv_have_decl_@var{symbol}}
variable, with characters not suitable for a variable name mapped to
@acindex{CHECK_DECLS}
@cvindex HAVE_DECL_@var{symbol}
@caindex have_decl_@var{symbol}
-For each of the @var{symbols} (@emph{comma}-separated list), define
+For each of the @var{symbols} (@emph{comma}-separated list with optional
+function argument types for C++ overloads), define
@code{HAVE_DECL_@var{symbol}} (in all capitals) to @samp{1} if
@var{symbol} is declared, otherwise to @samp{0}. If
@var{action-if-not-found} is given, it is additional shell code to
AC_CHECK_DECLS([strlen])
AC_CHECK_DECLS([malloc, realloc, calloc, free])
AC_CHECK_DECLS([j0], [], [], [[#include <math.h>]])
+AC_CHECK_DECLS([[basename(char *)], [dirname(char *)]])
@end example
Unlike the other @samp{AC_CHECK_*S} macros, when a @var{symbol} is not
# Shell function body for AC_CHECK_DECL.
m4_define([_AC_CHECK_DECL_BODY],
[ AS_LINENO_PUSH([$[]1])
- [as_decl_name=`echo $][2|sed 's/(.*//'`]
+ [as_decl_name=`echo $][2|sed 's/ *(.*//'`]
[as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
m4_define([_AC_CHECK_DECLS],
[AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
-[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[(.*])),
+[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
[$ac_have_decl],
[Define to 1 if you have the declaration of `$1',
and to 0 if you don't.])]dnl
struct { int x[20]; } mystruct;
extern int myfunc();
#define mymacro1(arg) arg
- #define mymacro2]])]],
+ #define mymacro2]])
+ # The difference in space-before-open-paren is intentional.
+ AC_CHECK_DECLS([basenam (char *), dirnam(char *),
+ [moreargs (char, short, int, long, void *, char [], float, double)]],,,
+ [[#ifdef __cplusplus
+ extern "C++" char *basenam (char *);
+ extern "C++" const char *basenam (const char *);
+ #else
+ extern char *basenam (const char *);
+ #endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ extern int moreargs (char, short, int, long, void *,
+ char [], float, double);
+ #ifdef __cplusplus
+ }
+ #endif
+ ]])
+ AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])],
+ [[#ifdef __cplusplus
+ extern "C++" char *declared (char *);
+ extern "C++" const char *declared (const char *);
+ #else
+ extern char *declared (const char *);
+ #endif
+ ]])
+ AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]])
+]],
[AT_CHECK_DEFINES(
-[#define HAVE_DECL_MYENUM 1
+[#define HAVE_DECL_BASENAM 1
+#define HAVE_DECL_DIRNAM 0
+#define HAVE_DECL_MOREARGS 1
+#define HAVE_DECL_MYENUM 1
#define HAVE_DECL_MYFUNC 1
#define HAVE_DECL_MYMACRO1 1
#define HAVE_DECL_MYMACRO2 1