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"
not
  extern "C" {
  #include "verify.h"
  }

As far as I can see from
https://isocpp.org/wiki/faq/mixing-c-and-cpp#include-c-hdrs-personal
https://devzone.nordicsemi.com/f/nordic-q-a/2590/please-can-you-add-extern-c-as-appropriate-to-your-header-files
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.

Bruno


Reply via email to