]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Define HAVE_DECL_FOO both to 1 if found and 0 otherwise.
authorAkim Demaille <akim@epita.fr>
Tue, 15 Feb 2000 09:33:59 +0000 (09:33 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 15 Feb 2000 09:33:59 +0000 (09:33 +0000)
* acgeneral.m4 (AC_CHECK_DECLS): Define HAVE_DECL_FOO to 1 instead
of NEED_FOO_DECL if found.  Define to 0 if not found.
* autoheader.m4 (AC_CHECK_DECLS): Template HAVE_DECL_FOO.
* tests/semantics.m4 (AC_CHECK_DECLS): Adjusted.
* doc/autoconf.texi (Generic Declarations): Adjusted.

ChangeLog
acgeneral.m4
autoconf.texi
autoheader.m4
doc/autoconf.texi
lib/autoconf/general.m4
tests/semantics.m4

index 1732d90e7fdecaaeeab7611149e0f23ea2afa37b..e661c1c498bbe8163a60c10522a2b32c7442bb11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-02-15  Akim Demaille  <akim@epita.fr>
+
+       Define HAVE_DECL_FOO both to 1 if found and 0 otherwise.
+
+       * acgeneral.m4 (AC_CHECK_DECLS): Define HAVE_DECL_FOO to 1 instead
+       of NEED_FOO_DECL if found.  Define to 0 if not found.
+       * autoheader.m4 (AC_CHECK_DECLS): Template HAVE_DECL_FOO.
+       * tests/semantics.m4 (AC_CHECK_DECLS): Adjusted.
+       * doc/autoconf.texi (Generic Declarations): Adjusted.
+
 2000-02-15  Akim Demaille  <akim@epita.fr>
 
        * doc/autoconf.texi (Generic Structures):
index 694423a26221781028831412732e43d17aee0719..c168d056c59578140ed3844d2f3756688426869c 100644 (file)
@@ -2691,11 +2691,15 @@ AC_VAR_POPDEF([ac_Symbol])dnl
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                [INCLUDES])
 # --------------------------------------------------------
+# Defines HAVE_DECL_SYMBOL to 1 if declared, 0 otherwise.  See the
+# documentation for a detailed explanation of this difference with
+# other AC_CHECK_*S macros.
 AC_DEFUN([AC_CHECK_DECLS],
 [m4_foreach([AC_Symbol], [$1],
   [AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol,
-                 [$2],
-                 [AC_DEFINE_UNQUOTED(AC_TR_CPP([NEED_]AC_Symbol[_DECL]))
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP([HAVE_DECL_]AC_Symbol), 1)
+$2],
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP([HAVE_DECL_]AC_Symbol), 0)
 $3],
                  [$4])])
 ])# AC_CHECK_DECLS
index 78085275386af1d2c9ae21a29b7f26b0c6c0f3c4..26ede389971155eb09cdfb801fa9e684ca216bb7 100644 (file)
@@ -3006,12 +3006,13 @@ introducing extra declarations when not needed.
 
 @defmac AC_CHECK_DECLS ((@var{symbol}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
 @maindex CHECK_DECLS
-@cvindex NEED_@var{symbol}_DECL
+@cvindex HAVE_DECL_@var{symbol}
 For each given @var{symbol} (comma separated list), define
-@code{NEED_@var{symbol}_DECL} (in all capitals) if @var{symbol} has to
-be declared to be used as an r-value.  If @var{action-if-not-found} is
-given, it is additional shell code to execute when one of the function
-declarations is needed, otherwise @var{action-if-found} is executed.
+@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
+execute when one of the function declarations is needed, otherwise
+@var{action-if-found} is executed.
 
 This macro uses an m4 list as first argument:
 @example
@@ -3019,22 +3020,34 @@ AC_CHECK_DECLS((strlen))
 AC_CHECK_DECLS((malloc, realloc, calloc, free))
 @end example
 
-This macro does not define @code{HAVE_@var{symbol}_DECL} on purpose.
-The following code
+Unlike the other @samp{AC_CHECK_*S} macros, when a @var{symbol} is not
+declared, @code{HAVE_DECL_@var{symbol}} is defined to @samp{0} instead
+of leaving @code{HAVE_DECL_@var{symbol}} undeclared.
+
+When you are @emph{sure} that the check was performed, use
+@code{HAVE_DECL_@var{symbol}} just like any other result of Autoconf:
+
 @example
-#if NEED_FOO_DECL
-/* Declare foo. */
+#if !HAVE_DECL_SYMBOL
+extern char *symbol;
 #endif
 @end example
-is safer than
+
+@noindent
+But if the test may have not been performed, because it is safer
+@emph{not} to declare a symbol than to use a declaration which conflicts
+with the system's one, you should use:
+
 @example
-#if !HAVE_FOO_DECL
-/* Declare foo. */
+#if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC
+char *malloc (size_t *s);
 #endif
 @end example
-since in this last case, if @code{configure} was not run, then the test
-succeeds, thus @code{foo} is declared, with risks to clash with previous
-declarations.  It is safer not to declare in case of doubts.
+
+@noindent
+You fall into the second category only in extreme situations: either
+your files may be used without being configured, or they are used during
+the configuration.  In most cases the traditional approach is enough.
 @end defmac
 
 
index 5da30d8d4ca6a6af2c6fc00b3cdf50049eec6198..981a759e0e81dd0b7efe5929a255b4d1ef65dd5e 100644 (file)
@@ -171,8 +171,9 @@ AH_DEFUN([AC_CHECK_FILES],
 
 AH_DEFUN([AC_CHECK_DECLS],
 [m4_foreach([AC_Symbol], [$1],
-  [AH_TEMPLATE(AC_TR_CPP([NEED_]AC_Symbol[_DECL]),
-               [Define if you need the declaration of `]AC_Symbol['.])
+  [AH_TEMPLATE(AC_TR_CPP([HAVE_DECL_]AC_Symbol),
+               [Define to 1 if you have the declaration of `]AC_Symbol[',
+                and to 0 if you don't.])
    # Success
    $2
    # Failure
index 78085275386af1d2c9ae21a29b7f26b0c6c0f3c4..26ede389971155eb09cdfb801fa9e684ca216bb7 100644 (file)
@@ -3006,12 +3006,13 @@ introducing extra declarations when not needed.
 
 @defmac AC_CHECK_DECLS ((@var{symbol}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
 @maindex CHECK_DECLS
-@cvindex NEED_@var{symbol}_DECL
+@cvindex HAVE_DECL_@var{symbol}
 For each given @var{symbol} (comma separated list), define
-@code{NEED_@var{symbol}_DECL} (in all capitals) if @var{symbol} has to
-be declared to be used as an r-value.  If @var{action-if-not-found} is
-given, it is additional shell code to execute when one of the function
-declarations is needed, otherwise @var{action-if-found} is executed.
+@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
+execute when one of the function declarations is needed, otherwise
+@var{action-if-found} is executed.
 
 This macro uses an m4 list as first argument:
 @example
@@ -3019,22 +3020,34 @@ AC_CHECK_DECLS((strlen))
 AC_CHECK_DECLS((malloc, realloc, calloc, free))
 @end example
 
-This macro does not define @code{HAVE_@var{symbol}_DECL} on purpose.
-The following code
+Unlike the other @samp{AC_CHECK_*S} macros, when a @var{symbol} is not
+declared, @code{HAVE_DECL_@var{symbol}} is defined to @samp{0} instead
+of leaving @code{HAVE_DECL_@var{symbol}} undeclared.
+
+When you are @emph{sure} that the check was performed, use
+@code{HAVE_DECL_@var{symbol}} just like any other result of Autoconf:
+
 @example
-#if NEED_FOO_DECL
-/* Declare foo. */
+#if !HAVE_DECL_SYMBOL
+extern char *symbol;
 #endif
 @end example
-is safer than
+
+@noindent
+But if the test may have not been performed, because it is safer
+@emph{not} to declare a symbol than to use a declaration which conflicts
+with the system's one, you should use:
+
 @example
-#if !HAVE_FOO_DECL
-/* Declare foo. */
+#if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC
+char *malloc (size_t *s);
 #endif
 @end example
-since in this last case, if @code{configure} was not run, then the test
-succeeds, thus @code{foo} is declared, with risks to clash with previous
-declarations.  It is safer not to declare in case of doubts.
+
+@noindent
+You fall into the second category only in extreme situations: either
+your files may be used without being configured, or they are used during
+the configuration.  In most cases the traditional approach is enough.
 @end defmac
 
 
index 694423a26221781028831412732e43d17aee0719..c168d056c59578140ed3844d2f3756688426869c 100644 (file)
@@ -2691,11 +2691,15 @@ AC_VAR_POPDEF([ac_Symbol])dnl
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                [INCLUDES])
 # --------------------------------------------------------
+# Defines HAVE_DECL_SYMBOL to 1 if declared, 0 otherwise.  See the
+# documentation for a detailed explanation of this difference with
+# other AC_CHECK_*S macros.
 AC_DEFUN([AC_CHECK_DECLS],
 [m4_foreach([AC_Symbol], [$1],
   [AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol,
-                 [$2],
-                 [AC_DEFINE_UNQUOTED(AC_TR_CPP([NEED_]AC_Symbol[_DECL]))
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP([HAVE_DECL_]AC_Symbol), 1)
+$2],
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP([HAVE_DECL_]AC_Symbol), 0)
 $3],
                  [$4])])
 ])# AC_CHECK_DECLS
index 47c12467cf3d512fa480634c20ae7bb4c3d7d49f..64993f499914a92559aac02d95bcba881d59e1f4 100644 (file)
@@ -16,8 +16,8 @@ AT_TEST_MACRO(AC_CHECK_DECLS,
 [AC_CHECK_DECLS((yes, no),,,
                 [int yes = 1;])],
 [AT_CHECK_DEFINES(
-[#define NEED_NO_DECL 1
-/* #undef NEED_YES_DECL */
+[#define HAVE_DECL_NO 0
+#define HAVE_DECL_YES 1
 ])])