Problem Background:
In ProjectA, agent_multi_threading.hpp
is inclueded in agent.h
.
In ProjectB, I'm trying to include agent.h
in processing_core.h
.
ProjectA is written in C while ProjectB is written in C++.
The code below shows the hierarchy of the including:
/* File: agent_multi_threading.hpp ProjectA */
#ifdef __cplusplus
#include <atomic>
using namespace std;
#else
/* File: agent.h in ProjectA */
#include "agent_multi_threading.hpp"
/* File: processing_core.h ProjectB */
extern "C" {
#include "agent.h"
}
Error Message:
In file included from /<compiler_path>/gnu/gcc/8.2.0/rhesys/include/c++/8.2.0/atomic:41,
from /<dir_path>/ProjectB/src/agent_multi_threading.hpp:30,
from /<dir_path>/ProjectB/src/agent.h:10,
from /<dir_path>/ProjectA/src/processing_core.cpp:5:
/<compiler_path>/gnu/gcc/8.2.0/rhesys/include/c++/8.2.0/bits/atomic_base.h:109:3: error: template with C linkage
template<typename _Tp>
^~~~~~~~
/<dir_path>/ProjectA/src/processing_core.cpp:5:1: note: 'extern "C"' linkage started here
extern "C" {
^~~~~~~~~~
from /<dir_path>/ProjectB/src/agent_multi_threading.hpp:30,
from /<dir_path>/ProjectB/src/agent.h:10,
from /<dir_path>/ProjectA/src/processing_core.cpp:5:
/<compiler_path>/gnu/gcc/8.2.0/rhesys/include/c++/8.2.0/atomic:62:3: error: template specialization with C linkage
template<>
^~~~~~~~
Q1. What are the meanings of "template with C linkage" and "template specialization with C linkage"?
Q2. Why is this happening in my code?