bug-autoconf
[Top][All Lists]
Advanced

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

strdup falsely detected when CFLAGS contains -ansi on MSYS/MinGW (gcc)


From: Chris Pickett
Subject: strdup falsely detected when CFLAGS contains -ansi on MSYS/MinGW (gcc)
Date: Sun, 28 Dec 2008 19:43:57 -0500
User-agent: Thunderbird 1.5.0.14 (Macintosh/20071210)

Hi,

When -ansi is passed to GCC, strdup becomes unavailable on MSYS/MinGW, but autoconf still detects the existence of strdup. The mingw string.h is in /mingw/include/string.h, and includes some funny stuff with #ifndef __STRICT_ANSI__ and later #ifndef _NO_OLDNAMES. The former gets defined by GCC with -ansi, the latter I couldn't see where it gets defined if at all.

Chris

mkdir src
cat >configure.ac <<\END
AC_INIT(a,1)
AM_INIT_AUTOMAKE(foreign)
AC_CONFIG_FILES(Makefile src/Makefile)
AC_PROG_CC
AC_PROG_LIBTOOL
AC_REPLACE_FUNCS([strdup])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT
END
cat >Makefile.am <<\END
SUBDIRS = src
END
cat >src/Makefile.am <<\END
libcheck_la_LIBADD = @LTLIBOBJS@
lib_LTLIBRARIES = libcheck.la
END
cat >src/libcheck.c <<\END
#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <string.h>

#if !HAVE_STRDUP
char *strdup (const char *str);
#endif /* !HAVE_STRDUP */

void use_strdup (void)
{
  strdup (NULL);
}
END
cat >src/strdup.c <<\END
char *
strdup (const char *str)
{
  /* obviously this is broken */
  return NULL;
}
END

autoreconf -vif # all is fine, src/strdup.c is there

CFLAGS="-Wall -ansi" ./configure # says yes for strdup (incorrectly)

make # libcheck.c:13: warning: implicit declaration of function `strdup'

make clean

CFLAGS="-Wall" ./configure # says yes for strdup (correctly)

make # libcheck.c:13: warning: null argument where non-null required (arg 1)




reply via email to

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