From 939120e561c3ab906e31e24bd30d74622d35cb00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Fri, 10 Dec 2021 15:54:23 +0100
Subject: [PATCH] Configure: Improved exit(3C) C99 check.

Do not add C declarations behind #ifdef __cplusplus; it breaks
C++ compilers...

Fixes #10058 even more.
---
 src/aclocal.m4 | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/aclocal.m4 b/src/aclocal.m4
index d8f51a4f68..7d2da03166 100644
--- a/src/aclocal.m4
+++ b/src/aclocal.m4
@@ -45,15 +45,11 @@ if_autoconf(2,60,,[
     ORIG__AC_PROG_CC_STDC
     # Some C99 compilers default to -Werror,-Wimplicit-function-declaration
     # Attempt to find a suitable prototype for exit(3C).
-    _AC_PROG_CXX_EXIT_DECLARATION
-    if test -n "$ac_declaration"; then
-      if echo "$ac_declaration" | grep extern >/dev/null; then :; else
-        # Looks like valid C code.
-	echo '#ifndef __cplusplus' >>confdefs.h
-	echo $ac_declaration >>confdefs.h
-	echo '#endif' >>confdefs.h
-      fi
-    fi
+    _AC_COMPILE_IFELSE([@%:@ifdef __cplusplus
+      choke me
+@%:@endif], [
+      patsubst(_AC_PROG_CXX_EXIT_DECLARATION, [ifdef], [ifndef])
+    ])
   ])
 ])
 
-- 
GitLab