bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Including verify.h in C++ with C linkage


From: Alex
Subject: Re: Including verify.h in C++ with C linkage
Date: Sun, 17 Mar 2019 11:03:26 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Alex <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]