bug-autoconf
[Top][All Lists]
Advanced

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

Re: AC_CHECK_FUNC and C++


From: Werner LEMBERG
Subject: Re: AC_CHECK_FUNC and C++
Date: Fri, 21 Sep 2001 21:03:28 +0200 (CEST)

> | Nevertheless, this approach causes problems.  A user got the following
> | error message (omitting the `configure:xxxx' prefix):
> | 
> |   checking for mkstemp
> |   g++ -o conftest -O2  -s conftest.cc  >&5
> |   declaration of C function `char mkstemp()' conflicts with
> |   /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.0.1/include/stdlib.h:246:
> |     previous declaration `int mkstemp(char*)' here
> |   $? = 1
> | 
> | For C++, I need a proper way to specify the prototype.  What is the
> | best way in autoconf to do that?
> 
> Hm...  Maybe it is really time to completely revamp AC_CHECK_FUNC.
> First of all, it should run AC_CHECK_DECL on the appropriate headers
> before trying to emulate the proto.

Hmm, the standard AC_CHECK_DECL isn't suited for C++, so you should
define AC_CHECK_DECL(C) and AC_CHECK_DECL(C++)... But see below.

> # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
> m4_define([AC_LANG_FUNC_LINK_TRY(C++)],
> [AC_LANG_PROGRAM(
> [],
> [/* 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
> ])])

This can't work since `f' isn't declared, and casting is not a good
idea...

Shouldn't be the following sufficient for C++?  Is there really a need
for AC_CHECK_DECL(C++) at all?


  AC_DEFUN(GROFF_MKSTEMP,
  [AC_MSG_CHECKING([for mkstemp])
  AC_LANG_PUSH(C++)
  AC_LIBSOURCE(mkstemp.cc)
  AC_TRY_LINK([#include <stdlib.h>
  int (*f) (char *);],
  [f = mkstemp;],
  AC_MSG_RESULT(yes);AC_DEFINE(HAVE_MKSTEMP, 1,
                               [Define if you have mkstemp().]),
  AC_MSG_RESULT(no);_AC_LIBOBJ(mkstemp))
  AC_LANG_POP(C++)])


Thus we need something like

  AC_CHECK_FUNC_CXX([includes],
                    [return_type],
                    [function_name],
                    [parameters])

e.g.

  AC_CHECK_FUNC_CXX([#include <stdio.h>],
                    [FILE *],
                    [fopen]
                    [const char *, const char *])


    Werner



reply via email to

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