Ok, without including the whole codebase...
#ifdef KIT_EXPORTS
#define KIT_API __declspec(dllexport)
#define EXP_TEMPLATE
#else
#define KIT_API __declspec(dllimport)
#define EXP_TEMPLATE extern
#endif
#ifndef KIT_LINKED_LIST_H
#define KIT_LINKED_LIST_H
#includes ...
namespace Kit
{
template <class tmplt>
class KIT_API KitLinkedList
{
private:
...
public:
KitLinkedList()
{
...
}
KitLinkedList(tmplt obj)
{
...
}
KitLinkedList(const KitLinkedList& other)
{
...
}
~KitLinkedList()
{
...
}
void PushBack(tmplt obj)
{
KitLinkedListNode<tmplt>* addedNode = new KitLinkedListNode<tmplt>(obj);
tail->nextNode = addedNode;
tail = addedNode;
count++;
}
uint64_t Count()
{
return count;
}
KitLinkedListIterator<tmplt> GetIterator()
{
return KitLinkedListIterator<tmplt>(root->nextNode);
}
... some other happy functions live here
};
}
My non-dll code:
KitLinkedList<KitString> savedGameList = saveSet.ListSavedGames();
savedGameList.PushBack(KitString("blah"));
if (savedGameList.Count() > 0)
{
}
- I have a linked list template class declared and defined entirely in a .h file, inside a dll.
- I successfully use the template class outside of the dll, compiling, linking, and running
- Using some functions in the class cause a linker error.
savedGameList.Count() causes LNK2019, but the pushback() and getiterator() don't.