From: Alexandre Oliva <[EMAIL PROTECTED]>
   Date: 27 Jul 2000 14:16:14 -0300

   On Jul 24, 2000, Akim Demaille <[EMAIL PROTECTED]> wrote:

   > What would be the problem with enabling the use of the fourth
   > parameter of AC_CHECK_FUNCS?  AC_CHECK_FUNC(func, yes, no,
   > includes)?

   Even though C99 requires prototypes, older releases of the C
   Standard don't, and we can't modify autoconf in a way that makes it
   unusable for such environments.

But the proposed changes don't make autoconf unusable for pre-C99.
The C standard has always required that an include file must declare
each function, even those returning `int'.  And even with K&R C, if
the function does not return `int', a declaration is required.

So the only problem is handling functions returning `int', with K&R C
include files that do not declare `int' functions.  This used to be a
serious problem, but it's not important any more as those old
platforms are vanishing.  A maintainer who still wants to cater to
this problem can use a traditional AC_CHECK_FUNC (i.e. without the
includes) for functions returning `int'.  But I suggest not bothering
to do this, as the only downside of the proposed new AC_CHECK_FUNC is
that an application will mistakenly avoid predefined `int' functions
on ancient platforms, and avoiding functionality normally isn't a
problem.

   We could then have an additional argument, in AC_CHECK_FUNC, if not
   in AC_CHECK_FUNCS, that would provide fallback declarations of
   functions whose declarations are missing.

But the fallback declarations may disagree with the actual signature
of those functions.  I dislike AC_CHECK_DECL for this reason.  It's
generally simpler and safer to avoid a function entirely if it's not
declared.

Here's an example of why the current AC_CHECK_FUNC is a problem: RCS
5.6.7.4 caused the HP-UX 8.07 OS to crash!  RCS used a test like the
current AC_CHECK_FUNC, and this test found mmap even though mmap
wasn't declared.  (HP-UX 8.07 mmap is a private interface, not
intended to be used by applications, and this is why it wasn't
declared.)  It would have been better had RCS checked for mmap's
declaration, and avoided mmap if it wasn't declared.
   
   As a side effect, AC_CHECK_FUNC would now implicitly perform the
   AC_CHECK_DECL test for functions.

Something like that might work, but it is complicated.  Let's use a
simpler approach instead.  If the new AC_CHECK_FUNC succeeds, we can
assume that the function is properly declared.  This is much easier to
document and use.

With the proposed change to AC_CHECK_FUNC, we can remove
AC_CHECK_DECL, as it's not needed.  This is a win, as AC_CHECK_DECL is
a pain to use correctly.  (We don't have to deprecate AC_CHECK_DECL,
as it wasn't in autoconf 2.13.)

Reply via email to