[Top][All Lists]

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

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

From: Bruno Haible
Subject: Re: Including verify.h in C++ with C linkage
Date: Sun, 17 Mar 2019 19:34:31 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

Hi Alex,

> > 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>

You are supposed to do
  #include "verify.h"
  extern "C" {
  #include "verify.h"

As far as I can see from
the preferred way to include .h files in C++ is like
  #include "verify.h"

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

Not really. We have enough work testing our .h files in 2 situations:
  - included from C
  - included from C++
Making our .h file work in 3 situations
  - included from C
  - included from C++
  - included from C++ inside extern "C" {}
makes for extra effort, with no real gain.


reply via email to

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