Skip to content

Compile error: template with C linkage #19

@maciejjan

Description

@maciejjan

Hello,

while compiling the package, I get a long list of errors of the sort:

In file included from /home/janicki/projects/comphist/norma/src/gfsm/labelvector.h:21,
                 from /home/janicki/projects/comphist/norma/src/gfsm/labelvector.cpp:18:
/home/janicki/projects/comphist/norma/src/gfsmlibs.h:20:1: note: ‘extern "C"’ linkage started here
   20 | extern "C" {
      | ^~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,
                 from /usr/include/glib-2.0/glib/gatomic.h:28,
                 from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from /home/janicki/.local/include/gfsm/gfsm.h:40,
                 from /home/janicki/projects/comphist/norma/src/gfsmlibs.h:21,
                 from /home/janicki/projects/comphist/norma/src/gfsm/labelvector.h:21,
                 from /home/janicki/projects/comphist/norma/src/gfsm/labelvector.cpp:18:
/usr/include/c++/11/type_traits:2525:3: error: template with C linkage
 2525 |   template<typename _MemPtr, typename _Arg, typename... _Args>
      |   ^~~~~~~~

The errors trace to glib, so I thought that maybe it needs to be included outside of the extern "C" block. I applied the following change:

--- a/src/gfsmlibs.h
+++ b/src/gfsmlibs.h
@@ -17,6 +17,7 @@
  */
 #ifndef GFSM_LIBRARIES_H_
 #define GFSM_LIBRARIES_H_
+#include<glib.h>
 extern "C" {
 #include<gfsm.h>
 #include<gfsmxl.h>

after which the code compiles. I don't know whether this is the correct solution though.

System info:

  • Ubuntu 22.2
  • g++ version: g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
  • glib package: libglib2.0-dev-bin/jammy,now 2.72.1-1 amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions