autoconf
[Top][All Lists]
Advanced

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

Re: Possible bug in many acspecific tests under AC_LANG(C++)


From: Paul Eggert
Subject: Re: Possible bug in many acspecific tests under AC_LANG(C++)
Date: Tue, 28 May 2002 17:19:01 -0700 (PDT)

> From: Nix <address@hidden>
> Date: 28 May 2002 23:40:10 +0100
> 
> I'd say that autoconf needs to support AC_FUNC checks *somehow* in the
> presence of AC_LANG(C++),

The *somehow* will involve changes to the macro arguments, since you
can't test for the presence of a function in C++ without knowing how
the function gets declared.

Here's an idea.  To test whether $ac_func exists, AC_CHECK_FUNC,
AC_CHECK_FUNCS, and AC_REPLACE_FUNCS currently try to link a program
that looks like this:

        #include "confdefs.h"
        /* System header to define __stub macros and hopefully few prototypes,
            which can conflict with char $ac_func (); below.  */
        #include <assert.h>
        /* Override any gcc2 internal prototype to avoid an error.  */
        #ifdef __cplusplus
        extern "C"
        #endif
        /* We use char because int might match the return type of a gcc2
           builtin and then its argument prototype would still apply.  */
        char $ac_func ();
        char (*f) ();

        #ifdef F77_DUMMY_MAIN
        #  ifdef __cplusplus
             extern "C"
        #  endif
           int F77_DUMMY_MAIN() { return 1; }
        #endif
        int
        main ()
        {
        /* The GNU C library defines this for functions which it implements
            to always fail with ENOSYS.  Some functions are actually named
            something starting with __ and the normal name is an alias.  */
        #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
        choke me
        #else
        f = $ac_func;
        #endif

          ;
          return 0;
        }

We could change Autoconf so that it first tries to link this program
instead:

        #include "confdefs.h"
        [Put the standard includes here.]

        int
        main ()
        {
        #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
        choke me
        #else
          return $ac_func != 0;
        #endif
        }

If this works, the function exists; otherwise, 'configure' should fall
back on trying to link the old program.

We need the fallback because many hosts still don't declare functions.
Once C99 takes over the world, we can remove the fallback, since C99
requires that all functions must be declared.

I don't know how this affects Fortran.  Maybe it'll need the fallback
indefinitely.



reply via email to

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