bug-autoconf
[Top][All Lists]
Advanced

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

Re: strdup falsely detected when CFLAGS contains -ansi on MSYS/MinGW (gc


From: Chris Pickett
Subject: Re: strdup falsely detected when CFLAGS contains -ansi on MSYS/MinGW (gcc)
Date: Mon, 29 Dec 2008 18:06:34 -0500
User-agent: Thunderbird 1.5.0.14 (Macintosh/20071210)

Hi Eric,

Eric Blake wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Chris Pickett on 12/29/2008 2:25 AM:
If you want to use extensions you should use AC_USE_SYSTEM_EXTENSIONS.
I tried adding this before AC_PROG_CC in my example and I get the same
result for mingw.

AC_USE_SYSTEM_EXTENSIONS should come AFTER AC_PROG_CC.

In this case, it still doesn't make a difference. I looked at the output from configure and it seems like it gets run after AC_PROG_CC regardless, i.e. `checking for minix/config.h usability' comes after `checking for unistd.h' and all the other C compiler stuff.

Nevertheless, maybe you want 1.patch.

  The other thing
that you need to realize is that AC_REPLACE_FUNCS([strdup]) merely checks
whether strdup is linkable (for your platform, it always is), not whether
it is declared (with -ansi, it is not).  Therefore, you need to complement
it with AC_CHECK_DECLS([strdup]) and provide your own declaration of
strdup if HAVE_DECL_STRDUP is 0.

Ah, now I understand how that all works.  Thank-you.  It's fixed.

Maybe you want 2.patch. I'm not sure if what I wrote is correct, but I didn't find any indications to the contrary.

Finally, I suggest a macro that combines AC_REPLACE_FUNCS and AC_CHECK_DECLS and that this new macro become the recommended usage. On the other hand, is there ever a time that you explicitly don't want a function to be listed in both AC_REPLACE_FUNCS and AC_CHECK_DECLS? If not, maybe you can simply get AC_REPLACE_FUNCS to run AC_CHECK_DECLS.

Cheers,
Chris

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index d619578..fcccaa4 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7691,8 +7691,8 @@ extensions to C, as well as platform extensions not 
defined by Posix.
 This macro was introduced in Autoconf 2.60.  If possible, enable
 extensions to C or Posix on hosts that normally disable the extensions,
 typically due to standards-conformance namespace issues.  This should be
-called before any macros that run the C compiler.  The following
-preprocessor macros are defined where appropriate:
+called before any macros that run the C compiler, but after AC_PROG_CC.
+The following preprocessor macros are defined where appropriate:
 
 @table @code
 @item _GNU_SOURCE
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index d619578..483fbbf 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -5282,12 +5282,17 @@ a convenient shorthand.
 @acindex{REPLACE_FUNCS}
 @cvindex address@hidden
 @ovindex LIBOBJS
-Like @code{AC_CHECK_FUNCS}, but uses @samp{AC_LIBOBJ(@var{function})} as
address@hidden  You can declare your replacement function by
-enclosing the prototype in @samp{#ifndef address@hidden  If the
-system has the function, it probably declares it in a header file you
-should be including, so you shouldn't redeclare it lest your declaration
-conflict.
+Like @code{AC_CHECK_FUNCS}, but uses @samp{AC_LIBOBJ(address@hidden)}
+as @var{action-if-not-found}.  Note that even if a function is found in
+a library, it may not be declared, so you should also run
address@hidden(address@hidden)} (@pxref{AC_CHECK_DECLS}).  Once
+both @samp{AC_REPLACE_FUNCS(address@hidden)} and
address@hidden(address@hidden)} are run, then
address@hidden implies @var{HAVE_FUNCTION}, but
address@hidden does not imply @var{HAVE_DECL_FUNCTION}.  Thus you
+can safely declare your replacement function by enclosing the prototype
+in @samp{#ifndef HAVE_DECL_FUNCTION}.  This avoids redeclaring the
+function in the event you simply forgot to include its header file.
 @end defmac
 
 @node Header Files

reply via email to

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