Here is my template function
template<typename T> std::stringstream logging_expansion ( T const * value ){
std::stringstream retval;
retval = retval << *value;
return retval;
}
Here is how i call it to use it
logging_expansion( "This is the log comes from the convinient function");
But the linker is telling me that it can not reference the function:
Undefined symbols for architecture x86_64:
"std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > logging_expansion<char>(char const*)", referenced from:
_main in WirelessAutomationDeviceXpcService.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to provide the implementation of template functions in header files or define the specialization in the header.
I’m assuming you currently have something like:
So you need to move the implementation to the header: