[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_CHECK_FUNC and C++
From: |
Akim Demaille |
Subject: |
Re: AC_CHECK_FUNC and C++ |
Date: |
27 Sep 2001 12:57:48 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
>>>>> "Paul" == Paul Eggert <address@hidden> writes:
>> From: Akim Demaille <address@hidden> Date: 21 Sep 2001 17:10:57
>> +0200
>>
>> Hm... Maybe it is really time to completely revamp AC_CHECK_FUNC.
Paul> I tend to agree.
>> First of all, it should run AC_CHECK_DECL on the appropriate
>> headers before trying to emulate the proto.
Paul> But then, why do you need AC_CHECK_FUNC at all? To catch the
Paul> case when a function is declared but is not defined in a
Paul> library? I don't think this happens often.
Autoconf is not here to make assumptions over `often' :)
More seriously, are you saying that we should move our model from
`function present = can be linked' to `function present = is declared
in the headers'?
Maybe it is too soon. Or are you referring to C++ only? Gosh,
AC_CHECK should have an lang independent algorithm, IMHO.
That's why I would promote AC_CHECK_FUNC as first looking for the
decl, then for the linkability.
Paul, there is something that seriously annoys me in Autoconf, and I
asked for help several times, but never really totally understood the
answers: why the heck do we have two means to check for the presence
of a function?
lib/autoconf/c.m4:
for AC_CHECK_FUNC
| # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
| # -----------------------------------
| # Avoid conflicting decl of main.
| m4_define([AC_LANG_CALL(C)],
| [AC_LANG_PROGRAM([$1
| m4_if([$2], [main], ,
| [/* 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 $2 ();])], [$2 ();])])
for AC_TRY_LINK_FUNC
| # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
| # ----------------------------------
| # Don't include <ctype.h> because on OSF/1 3.0 it includes
| # <sys/types.h> which includes <sys/select.h> which contains a
| # prototype for select. Similarly for bzero.
| m4_define([AC_LANG_FUNC_LINK_TRY(C)],
| [AC_LANG_PROGRAM(
| [/* System header to define __stub macros and hopefully few prototypes,
| which can conflict with char $1 (); 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 $1 ();
| char (*f) ();
| ],
| [/* 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_$1) || defined (__stub___$1)
| choke me
| #else
| f = $1;
| #endif
| ])])
|
I would feel mcuh better to have only *one*. Let's make this a first
step, then we will handle the C++ stuff. My idea is (i), promote the
use of $4 for includes, and (ii), promote the use of M4-list for $1
which would make it possible to pass actual arguments to functions.