Commit 1c8244ec authored by Tom Lane's avatar Tom Lane

Twiddle C++ configuration checks so that we #include <string> (if

it exists) before testing 'using namespace std'.  This is necessary
on some C++ setups where the compiler won't take a 'using' until
you've included a header that mentions namespace std.  (Pretty braindead
if you ask me, but...)
parent ac663748
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -490,6 +490,7 @@ AC_SUBST(USE_ODBC)
AC_SUBST(MULTIBYTE)
dnl Check for C++ support (allow override if needed)
dnl XXX: probably should default to HAVECXX='false'
HAVECXX='true'
AC_ARG_WITH(CXX,
[ --with-CXX=compiler use specific C++ compiler
......@@ -497,29 +498,25 @@ AC_ARG_WITH(CXX,
[
case "$withval" in
"" | y | ye | yes)
AC_MSG_ERROR([*** You must supply an argument to the --with-CC option.])
HAVECXX='true'
# allow configure to choose C++ compiler
;;
n | no)
HAVECXX='false'
;;
esac
*)
HAVECXX='true'
CXX="$withval"
],
[ AC_PROG_CXX])
;;
esac
])
AC_SUBST(HAVECXX)
if test "$HAVECXX" = 'true' ; then
dnl Even if CXX value was given to us, need to run AC_PROG_CXX ...
AC_PROG_CXX
AC_LANG_CPLUSPLUS
dnl check whether "using namespace std" works on this C++ compiler
AC_MSG_CHECKING([for namespace std in C++])
AC_TRY_COMPILE([#include <stdio.h>
#include <stdlib.h>
using namespace std;
], [],
[AC_DEFINE(HAVE_NAMESPACE_STD) AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
dnl check whether "#include <string>" works on this C++ compiler
AC_MSG_CHECKING([for include <string> in C++])
AC_TRY_COMPILE([#include <stdio.h>
......@@ -547,7 +544,23 @@ system's C++ header files.
HAVECXX='false'
])
])
fi
if test "$HAVECXX" = 'true' ; then
dnl check whether "using namespace std" works on this C++ compiler.
dnl NOTE: on at least some compilers, it will not work until you've
dnl included a header that mentions namespace std. Thus, include
dnl the usual suspects before trying it.
AC_MSG_CHECKING([for namespace std in C++])
AC_TRY_COMPILE([#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_CXX_STRING_HEADER
#include <string>
#endif
using namespace std;
], [],
[AC_DEFINE(HAVE_NAMESPACE_STD) AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
fi
dnl make sure we revert to C compiler, not C++, for subsequent tests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment