unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] util: make remaining headers includable from C++
@ 2019-03-02 20:26 David Bremner
  2019-03-05  1:52 ` Matt Armstrong
  2019-03-12 10:54 ` David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: David Bremner @ 2019-03-02 20:26 UTC (permalink / raw)
  To: notmuch

libnotmuch_util.a is supposed to be usable from the library and the
CLI, but much the library is compiled as C++. Add in appropriate
wrapping to prevent symbol mangling. These wrappers already existed in
string-util.h; it seems better to be consistent.
---
 util/crypto.h       |  7 +++++++
 util/error_util.h   |  7 +++++++
 util/gmime-extra.h  | 12 +++++++++---
 util/hex-escape.h   |  9 +++++++++
 util/talloc-extra.h |  8 ++++++++
 util/xutil.h        |  8 ++++++++
 util/zlib-extra.h   |  9 +++++++++
 7 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/util/crypto.h b/util/crypto.h
index c384601c..1a90f0e0 100644
--- a/util/crypto.h
+++ b/util/crypto.h
@@ -5,6 +5,10 @@
 #include "gmime-extra.h"
 #include "notmuch.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct _notmuch_crypto {
     bool verify;
     notmuch_decryption_policy_t decrypt;
@@ -34,4 +38,7 @@ _notmuch_crypto_get_gmime_ctx_for_protocol (_notmuch_crypto_t *crypto,
 void
 _notmuch_crypto_cleanup (_notmuch_crypto_t *crypto);
 
+#ifdef __cplusplus
+}
+#endif
 #endif
diff --git a/util/error_util.h b/util/error_util.h
index 4bb338a2..aa3b77c4 100644
--- a/util/error_util.h
+++ b/util/error_util.h
@@ -25,6 +25,10 @@
 
 #include "function-attributes.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* There's no point in continuing when we've detected that we've done
  * something wrong internally (as opposed to the user passing in a
  * bogus value).
@@ -44,4 +48,7 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2) NORETURN_ATTRI
     _internal_error (format " (%s).\n",			\
 		     ##__VA_ARGS__, __location__)
 
+#ifdef __cplusplus
+}
+#endif
 #endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index ca822b8c..5d8c52f7 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -1,11 +1,13 @@
 #ifndef _GMIME_EXTRA_H
 #define _GMIME_EXTRA_H
 #include <gmime/gmime.h>
-
-GMimeStream *g_mime_stream_stdout_new(void);
-
 #include <talloc.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+GMimeStream *g_mime_stream_stdout_new(void);
 
 #if (GMIME_MAJOR_VERSION < 3)
 
@@ -100,4 +102,8 @@ gint64 g_mime_utils_header_decode_date_unix (const char *date);
  */
 const char * g_mime_certificate_get_valid_userid (GMimeCertificate *cert);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/util/hex-escape.h b/util/hex-escape.h
index 5182042e..50d946ed 100644
--- a/util/hex-escape.h
+++ b/util/hex-escape.h
@@ -1,6 +1,10 @@
 #ifndef _HEX_ESCAPE_H
 #define _HEX_ESCAPE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef enum hex_status {
     HEX_SUCCESS = 0,
     HEX_SYNTAX_ERROR,
@@ -38,4 +42,9 @@ hex_decode (void *talloc_ctx, const char *in, char **out,
  */
 hex_status_t
 hex_decode_inplace (char *s);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/util/talloc-extra.h b/util/talloc-extra.h
index eac5dc05..e2e61734 100644
--- a/util/talloc-extra.h
+++ b/util/talloc-extra.h
@@ -3,6 +3,10 @@
 
 #include <talloc.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Like talloc_strndup, but take an extra parameter for the internal talloc
  * name (for debugging) */
 
@@ -15,4 +19,8 @@ talloc_strndup_named_const (void *ctx, const char *str,
 
 #define talloc_strndup_debug(ctx, str, len) talloc_strndup_named_const (ctx, str, len, __location__)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/util/xutil.h b/util/xutil.h
index 4829f33c..e2707000 100644
--- a/util/xutil.h
+++ b/util/xutil.h
@@ -25,6 +25,10 @@
 #include <sys/types.h>
 #include <regex.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* xutil.c */
 void *
 xcalloc (size_t nmemb, size_t size);
@@ -49,4 +53,8 @@ int
 xregexec (const regex_t *preg, const char *string,
 	  size_t nmatch, regmatch_t pmatch[], int eflags);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/util/zlib-extra.h b/util/zlib-extra.h
index aedfd48f..209fa998 100644
--- a/util/zlib-extra.h
+++ b/util/zlib-extra.h
@@ -4,6 +4,10 @@
 #include "util.h"
 #include <zlib.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Like getline, but read from a gzFile. Allocation is with talloc.
  * Returns:
  *
@@ -22,4 +26,9 @@ gz_getline (void *ctx, char **lineptr, ssize_t *bytes_read, gzFile stream);
 
 const char *
 gz_error_string (util_status_t status, gzFile stream);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] util: make remaining headers includable from C++
  2019-03-02 20:26 [PATCH] util: make remaining headers includable from C++ David Bremner
@ 2019-03-05  1:52 ` Matt Armstrong
  2019-03-12 10:54 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Armstrong @ 2019-03-05  1:52 UTC (permalink / raw)
  To: David Bremner, notmuch

Looks good.  While C++ long ago abandoned the idea that it was a perfect
C compatible superset, I can't see anything in these .h files that has
any danger of being interpreted differently across the two languages.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] util: make remaining headers includable from C++
  2019-03-02 20:26 [PATCH] util: make remaining headers includable from C++ David Bremner
  2019-03-05  1:52 ` Matt Armstrong
@ 2019-03-12 10:54 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2019-03-12 10:54 UTC (permalink / raw)
  To: notmuch

David Bremner <david@tethera.net> writes:

> libnotmuch_util.a is supposed to be usable from the library and the
> CLI, but much the library is compiled as C++. Add in appropriate
> wrapping to prevent symbol mangling. These wrappers already existed in
> string-util.h; it seems better to be consistent.

pushed,

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-12 10:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-02 20:26 [PATCH] util: make remaining headers includable from C++ David Bremner
2019-03-05  1:52 ` Matt Armstrong
2019-03-12 10:54 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).