0

I have an overloaded function which accepts two different types of parameter (factorywv) as below. I am working under Solaris environment.

typedef AISObject *(*factorywv)();
namespace bcMwMrsh
{
 template<typename listT>
 void cppListFromWire(void *&src,RWTValSlist<listT> &dest, factorywv);
} 

int FormAccountSetupList::fromWire(void *&buf, long bufLen)
{
        bcMwMrsh::cppListFromWire(buf, contents, FormAccountSetupRow::AISFactory);
        return 0;
}

AISFactory and contents are defined as below,

static AISObject *AISFactory() { return new FormAccountSetupList; }
RWTValSlist<FormAccountSetupRow *> contents;

These two functions are called in different cpp files. Currently I am facing the below error and understood function template may solve the problem.

Undefined                       first referenced
 symbol                             in file
void bcMwMrsh::cppListFromWire<FormATMSetupRow*>(void*&, RWTValSlist<FormATMSetupRow*, std::allocator<FormATMSetupRow*> >&, AISObject* (*)()) actsetup.o

Could some one please let me know how can I convert the typdefs to templatized form? Or my understanding of the problem is correct?

Puneeth
  • 419
  • 1
  • 6
  • 18
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Jesper Juhl Oct 06 '22 at 13:44
  • I don't see how this has anything to do with `typedef`. – Jesper Juhl Oct 06 '22 at 13:45
  • You simply need to provide a definition for your `cppListFromWire` function. – Erlkoenig Oct 06 '22 at 14:42
  • Definition already exists but the point how to link it in the runtime – Puneeth Oct 07 '22 at 06:17
  • [Why can templates only be implemented in the header file?](https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file) Where exactly does the definition of `cppListFromWire` exist? – Igor Tandetnik Oct 07 '22 at 14:39
  • It does exists 2 places as below, it was initialy defined in cpp files which I commented to be defined in .h files. wv/include/cppmarsh.h and one more under bc/include/bcMwMrsh.h. Both has different implementations. template void cppListFromWire(void *&src,RWTValSlist &list, factorywv factoryFunc) – Puneeth Oct 10 '22 at 07:14

0 Answers0