On 11/1/20 10:04 PM, [email protected] wrote:
I am not yet sure to what end, but I've
been working on making gawk compile with g++.  For the moment I'm
leaving the support routines in C, but I needed this change
in dfa.h.

Thanks, I installed the attached slightly-fancier patch into Gnulib.
>From f11807fb540e1475fd4301944132b9602e05f302 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Mon, 2 Nov 2020 10:53:08 -0800
Subject: [PATCH] dfa.h: support inclusion from C++

* lib/dfa.h: Allow multiple inclusion, and inclusion from
C++ code.  The latter was suggested by Arnold Robbins.
---
 ChangeLog |  6 ++++++
 lib/dfa.h | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 2068ce6d2..bb30fcf1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-11-02  Paul Eggert  <[email protected]>
+
+	dfa.h: support inclusion from C++
+	* lib/dfa.h: Allow multiple inclusion, and inclusion from
+	C++ code.  The latter was suggested by Arnold Robbins.
+
 2020-11-01  Bruno Haible  <[email protected]>
 
 	ssfmalloc tests: Portability to Linux/PowerPC and Linux/SPARC.
diff --git a/lib/dfa.h b/lib/dfa.h
index 2f77f2638..654778972 100644
--- a/lib/dfa.h
+++ b/lib/dfa.h
@@ -18,10 +18,17 @@
 
 /* Written June, 1988 by Mike Haertel */
 
+#ifndef DFA_H_
+#define DFA_H_
+
 #include <regex.h>
 #include <stdbool.h>
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct localeinfo; /* See localeinfo.h.  */
 
 /* Element of a list of strings, at least one of which is known to
@@ -131,3 +138,9 @@ extern void dfawarn (const char *);
    takes a single argument, a NUL-terminated string describing the error.
    The user must supply a dfaerror.  */
 extern _Noreturn void dfaerror (const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* dfa.h */
-- 
2.25.1

Reply via email to