From ee7e69813784e7cf120165ba222e93f91d0d8f42 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 30 Aug 2016 12:00:00 -0400
Subject: [PATCH 04/27] Fix LDFLAGS test for C++

The test looks to link to particular function, so we need to make that
function have C linkage.
---
 config/c-compiler.m4 |  9 ++++++++-
 configure            | 27 ++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 7d901e1..21fb464 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -353,7 +353,14 @@ AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
 AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
 [pgac_save_LDFLAGS=$LDFLAGS
 LDFLAGS="$pgac_save_LDFLAGS $1"
-AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])],
+AC_RUN_IFELSE([AC_LANG_PROGRAM([#ifdef __cplusplus
+extern "C" {
+#endif
+extern void $2 ();
+#ifdef __cplusplus
+}
+#endif
+void (*fptr) () = $2;],[])],
               [Ac_cachevar=yes],
               [Ac_cachevar=no],
               [Ac_cachevar="assuming no"])
diff --git a/configure b/configure
index 2308c61..d74b25f 100755
--- a/configure
+++ b/configure
@@ -15748,7 +15748,14 @@ if test "$cross_compiling" = yes; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-extern void $link_test_func (); void (*fptr) () = $link_test_func;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void $link_test_func ();
+#ifdef __cplusplus
+}
+#endif
+void (*fptr) () = $link_test_func;
 int
 main ()
 {
@@ -15787,7 +15794,14 @@ if test "$cross_compiling" = yes; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-extern void $link_test_func (); void (*fptr) () = $link_test_func;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void $link_test_func ();
+#ifdef __cplusplus
+}
+#endif
+void (*fptr) () = $link_test_func;
 int
 main ()
 {
@@ -15826,7 +15840,14 @@ if test "$cross_compiling" = yes; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-extern void $link_test_func (); void (*fptr) () = $link_test_func;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void $link_test_func ();
+#ifdef __cplusplus
+}
+#endif
+void (*fptr) () = $link_test_func;
 int
 main ()
 {
-- 
2.9.3

