Alex <[email protected]> writes:

> Hello, I'm trying to use C++ in a project that uses Gnulib, and I need
> to use C linkage around a statement that eventually includes verify.h.
> However, this leads to the following error message:
>
>   ./lib/verify.h:178:1: error: template with C linkage
>    template <int w>
>
> Any way to successfully include this file in this context would be
> appreciated.
>
> Thanks for reading.

It figures that I found a way right after posting this; is the following
diff a good solution for upstream?

diff --git a/lib/verify.h b/lib/verify.h
index 6930645a35..785e3d6a82 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -175,11 +175,13 @@
 
 #ifdef __cplusplus
 # if !GNULIB_defined_struct__gl_verify_type
+extern "C++" {
 template <int w>
   struct _gl_verify_type {
     unsigned int _gl_verify_error_if_negative: w;
   };
 #  define GNULIB_defined_struct__gl_verify_type 1
+}
 # endif
 # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
     _gl_verify_type<(R) ? 1 : -1>

Reply via email to