probably you can use explicit intantiation technique.
e.g.
If you have a template function declared in a.h as
template<typename T>
void print(const T&);
and defined in a.c as
template<typename T>
void print(const T&)
{
......
}
Keep prepocessor guards in all the file which have to be #included
(a.h,a.c in this case).
Then you can have separate .h file say b.h in which you can explicitly
instantiate it as
//b.h
#include "a.c"
template void print<double/*Or whatever as per your implementation*/
>(const double&);
Link it with your test file.
//test.cpp
#include "a.h"
int main()
{
double d = 0.0;
print(d);
}
This method can also be used for class templates,member
functions,Template member functions.
Regards,
Siddhu