I never understood why the code between the two was different.  I
think it should not be, and the proposal from Paul (using `return
!the_function') seems like a very nice idea.

Translated from 2.13 into 2.50 the difference between those two macros
is expressed by the existence of the two following macros:

# AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
# -----------------------------------
# Avoid conflicting decl of main.
define([AC_LANG_CALL(C)],
[AC_LANG_PROGRAM([$1
ifelse([$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 ();])])


# 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.
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
])])


(AC_LANG_CALL is used by AC_TRY_LINK_FUNC, and AC_LANG_FUNC_LINK_TRY
by AC_CHECK_FUNC).


As you can see, the first one gives a default prototype for the
function, then tries to call it.

The second one tries to use a pointer to that function.  It has some
bizarre code I don't understand well :( Could someone give better
details on this issue?  It is the reason for the bizarre inclusion of
assert.h.  I'm not comfortable with this, it's coming from:

Fri Mar  3 11:41:01 1995  David J. MacKenzie  <[EMAIL PROTECTED]>

        * Makefile.in (autoconf.info, standards.info): Use --no-split to
         avoid creating filenames > 14 chars.

        * acgeneral.m4 (AC_CHECK_FUNC): Use assert.h,
         to avoid protype conflicts from ctype.h (!!) on OSF/1 3.0.

Fri Feb 24 20:02:08 1995  Roland McGrath  <[EMAIL PROTECTED]>

        * acgeneral.m4 (AC_CHECK_FUNC): Include errno.h instead of ctype.h
        in test program.




It is worth noting that:

1999-01-09  J"orn Rennecke  <[EMAIL PROTECTED]>

        * acgeneral.m4 (AC_CHECK_FUNC): Don't actually call the function.

unfortunately there is no further information :( Jörn, can you explain
this?  Is it to make the difference between macros and functions?




As a first simplifying step, I guess we can have AC_CHECK_FUNC and
AC_TRY_LINK_FUNC use this code:

# 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.
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 ();
],
[/* 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
return !$1;
#endif
])])

        Akim

Reply via email to