>>>>> "Ian" == Ian Lance Taylor <[EMAIL PROTECTED]> writes:

Ian> The GNU binutils use this macro to detect this case:

Ian> dnl See whether we need a declaration for a function.
Ian> AC_DEFUN(BFD_NEED_DECLARATION, 

There is something like this in Autoconf now:

Generic Declaration Checks
--------------------------

   These macros are used to find declarations not covered by the
particular test macros.

 - Macro: AC_CHECK_DECL (SYMBOL, [ACTION-IF-FOUND],
          [ACTION-IF-NOT-FOUND], [INCLUDES])
     If the declaration of SYMBOL (a function or a variable) is needed
     because it is not declared in INCLUDES, run the shell commands
     ACTION-IF-NOT-FOUND, otherwise ACTION-IF-FOUND.  If no INCLUDES
     are specified, the default includes are used (*note Default
     Includes::).

     This macro actually tests whether it is valid to use SYMBOL as an
     r-value, not if it is really declared, because it is much safer to
     avoid introducing extra declarations when not needed.

 - Macro: AC_CHECK_DECLS ((SYMBOL, ...), [ACTION-IF-FOUND],
          [ACTION-IF-NOT-FOUND], [INCLUDES])
     For each given SYMBOL (comma separated list), define
     `HAVE_DECL_SYMBOL' (in all capitals) to `1' if SYMBOL is declared,
     otherwise to `0'.  If ACTION-IF-NOT-FOUND is given, it is
     additional shell code to execute when one of the function
     declarations is needed, otherwise ACTION-IF-FOUND is executed.

     This macro uses an m4 list as first argument:
          AC_CHECK_DECLS((strlen))
          AC_CHECK_DECLS((malloc, realloc, calloc, free))

     Unlike the other `AC_CHECK_*S' macros, when a SYMBOL is not
     declared, `HAVE_DECL_SYMBOL' is defined to `0' instead of leaving
     `HAVE_DECL_SYMBOL' undeclared.

     When you are _sure_ that the check was performed, use
     `HAVE_DECL_SYMBOL' just like any other result of Autoconf:

          #if !HAVE_DECL_SYMBOL
          extern char *symbol;
          #endif

     But if the test may have not been performed, because it is safer
     _not_ to declare a symbol than to use a declaration which conflicts
     with the system's one, you should use:

          #if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC
          char *malloc (size_t *s);
          #endif

     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.

Akim

Reply via email to