Hi,
qsort() detection on Linux/glibc with g++ fails when C++ is set as the
test language. For example, the following:
AC_INIT([FOO],[TEST],[],[])
AC_PREREQ([2.57])
AC_PROG_CXX
AC_LANG([C++])
AC_CHECK_FUNC([qsort],[],[])
AC_OUTPUT
produces this output:
$ ./configure
checking for g++... g++
checking for C++ compiler default output... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for qsort... no
configure: creating ./config.status
The error is due to a function prototype conflict between the
prototype in test code and the one in <stdlib.h>. Here's the relevant
config.log excerpt:
configure:1754: checking for qsort
configure:1804: g++ -o conftest -g -O2 conftest.cc >&5
configure:1786: declaration of C function `char qsort()' conflicts with
/usr/include/stdlib.h:736: previous declaration `void qsort(void*, unsigned
int, unsigned int, int (*)(const void*, const void*))' here
<stdlib.h> is only include in the C++ case, which is why the error
doesn't appear in the C case. I assume that similar errors will occur
for other functions declared in <stdlib.h>. I can work around the
problem by temporarily setting the test language to C, but I'd prefer
not to have to do that. Any ideas?
The full `config.log' file is attached.
Thanks,
-Ossama
--
Ossama Othman <[EMAIL PROTECTED]>
Distributed Object Computing Laboratory, Univ. of California at Irvine
1024D/F7A394A8 - 84ED AA0B 1203 99E4 1068 70E6 5EB7 5E71 F7A3 94A8
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by FOO configure TEST, which was
generated by GNU Autoconf 2.57. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = tata
uname -m = i686
uname -r = 2.4.19
uname -s = Linux
uname -v = #13 Sat Sep 14 10:55:53 PDT 2002
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = i686
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/bin/X11
PATH: /usr/games
## ----------- ##
## Core tests. ##
## ----------- ##
configure:1276: checking for g++
configure:1292: found /usr/bin/g++
configure:1302: result: g++
configure:1318: checking for C++ compiler version
configure:1321: g++ --version </dev/null >&5
g++ (GCC) 3.2.3 20030309 (Debian prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:1324: $? = 0
configure:1326: g++ -v </dev/null >&5
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu
--enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.3 20030309 (Debian prerelease)
configure:1329: $? = 0
configure:1331: g++ -V </dev/null >&5
g++: argument to `-V' missing
configure:1334: $? = 1
configure:1358: checking for C++ compiler default output
configure:1361: g++ conftest.cc >&5
configure:1364: $? = 0
configure:1410: result: a.out
configure:1415: checking whether the C++ compiler works
configure:1421: ./a.out
configure:1424: $? = 0
configure:1441: result: yes
configure:1448: checking whether we are cross compiling
configure:1450: result: no
configure:1453: checking for suffix of executables
configure:1455: g++ -o conftest conftest.cc >&5
configure:1458: $? = 0
configure:1483: result:
configure:1489: checking for suffix of object files
configure:1511: g++ -c conftest.cc >&5
configure:1514: $? = 0
configure:1536: result: o
configure:1540: checking whether we are using the GNU C++ compiler
configure:1565: g++ -c conftest.cc >&5
configure:1568: $? = 0
configure:1571: test -s conftest.o
configure:1574: $? = 0
configure:1587: result: yes
configure:1593: checking whether g++ accepts -g
configure:1615: g++ -c -g conftest.cc >&5
configure:1618: $? = 0
configure:1621: test -s conftest.o
configure:1624: $? = 0
configure:1635: result: yes
configure:1679: g++ -c -g -O2 conftest.cc >&5
configure:1682: $? = 0
configure:1685: test -s conftest.o
configure:1688: $? = 0
configure:1715: g++ -c -g -O2 conftest.cc >&5
configure: In function `int main()':
configure:1710: `exit' undeclared (first use this function)
configure:1710: (Each undeclared identifier is reported only once for each
function it appears in.)
configure:1718: $? = 1
configure: failed program was:
| #line 1698 "configure"
| /* confdefs.h. */
|
| #define PACKAGE_NAME "FOO"
| #define PACKAGE_TARNAME "foo"
| #define PACKAGE_VERSION "TEST"
| #define PACKAGE_STRING "FOO TEST"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h. */
|
| int
| main ()
| {
| exit (42);
| ;
| return 0;
| }
configure:1679: g++ -c -g -O2 conftest.cc >&5
configure:1682: $? = 0
configure:1685: test -s conftest.o
configure:1688: $? = 0
configure:1715: g++ -c -g -O2 conftest.cc >&5
configure:1718: $? = 0
configure:1721: test -s conftest.o
configure:1724: $? = 0
configure:1754: checking for qsort
configure:1804: g++ -o conftest -g -O2 conftest.cc >&5
configure:1786: declaration of C function `char qsort()' conflicts with
/usr/include/stdlib.h:736: previous declaration `void qsort(void*, unsigned
int, unsigned int, int (*)(const void*, const void*))' here
configure:1807: $? = 1
configure: failed program was:
| #line 1759 "configure"
| /* confdefs.h. */
|
| #define PACKAGE_NAME "FOO"
| #define PACKAGE_TARNAME "foo"
| #define PACKAGE_VERSION "TEST"
| #define PACKAGE_STRING "FOO TEST"
| #define PACKAGE_BUGREPORT ""
| #ifdef __cplusplus
| #include <stdlib.h>
| #endif
| /* end confdefs.h. */
| /* System header to define __stub macros and hopefully few prototypes,
| which can conflict with char qsort (); below.
| Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
| <limits.h> exists even on freestanding compilers. */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
| /* 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 qsort ();
| /* 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_qsort) || defined (__stub___qsort)
| choke me
| #else
| char (*f) () = qsort;
| #endif
| #ifdef __cplusplus
| }
| #endif
|
| int
| main ()
| {
| return f != qsort;
| ;
| return 0;
| }
configure:1824: result: no
configure:1953: creating ./config.status
## ---------------------- ##
## Running config.status. ##
## ---------------------- ##
This file was extended by FOO config.status TEST, which was
generated by GNU Autoconf 2.57. Invocation command line was
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
$ ./config.status
on tata
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_cxx_compiler_gnu=yes
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CXXFLAGS_set=
ac_cv_env_CXXFLAGS_value=
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_exeext=
ac_cv_func_qsort=no
ac_cv_objext=o
ac_cv_prog_ac_ct_CXX=g++
ac_cv_prog_cxx_g=yes
## ----------------- ##
## Output variables. ##
## ----------------- ##
CPPFLAGS=''
CXX='g++'
CXXFLAGS='-g -O2'
DEFS='-DPACKAGE_NAME=\"FOO\" -DPACKAGE_TARNAME=\"foo\" -DPACKAGE_VERSION=\"TEST\"
-DPACKAGE_STRING=\"FOO\ TEST\" -DPACKAGE_BUGREPORT=\"\" '
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EXEEXT=''
LDFLAGS=''
LIBOBJS=''
LIBS=''
LTLIBOBJS=''
OBJEXT='o'
PACKAGE_BUGREPORT=''
PACKAGE_NAME='FOO'
PACKAGE_STRING='FOO TEST'
PACKAGE_TARNAME='foo'
PACKAGE_VERSION='TEST'
PATH_SEPARATOR=':'
SHELL='/bin/sh'
ac_ct_CXX='g++'
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${prefix}/share'
exec_prefix='${prefix}'
host_alias=''
includedir='${prefix}/include'
infodir='${prefix}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localstatedir='${prefix}/var'
mandir='${prefix}/man'
oldincludedir='/usr/include'
prefix='/usr/local'
program_transform_name='s,x,x,'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
#define PACKAGE_BUGREPORT ""
#define PACKAGE_NAME "FOO"
#define PACKAGE_STRING "FOO TEST"
#define PACKAGE_TARNAME "foo"
#define PACKAGE_VERSION "TEST"
#endif
#ifdef __cplusplus
#include <stdlib.h>
configure: exit 0