Having the smart pointer code embedded in both my DLL and my main app, it seems that TWO objects are created and the static members, the map and lock, are not the same across the DLL boundaries.
I'm guess I'm going to have to imbed it into the DLL and export the class to the app.
EDIT:
As usual, when I try to export the class, I get linking errors instead:
Code:
template<typename T> class AFX_EXT_CLASS CMemoryManager;
2>Do X For Every FileDlg.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CMemoryManager<class std::vector<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class std::allocator<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > > >::~CMemoryManager<class std::vector<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class std::allocator<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > > > >(void)" referenced in function "public: void __thiscall CDoXForEveryFileDlg::OnBnClickedBrowseapp(void)"
I was also unable to map these into definitions in the .cpp file:
Code:
template<typename NewT> operator CMemoryManager<NewT>& () const;
template<typename T2> static CMemoryManager<T> MemoryManagerNew(T2* pNew) throw(...);
CMemoryManagerTimeCritical& operator = (T* p) throw(...) { CMemoryManager<T>::operator = (p); return *this; }
CMemoryManagerTimeCritical& operator = (CMemoryManagerTimeCritical<T>& r) throw(...);
//template<typename T, typename T2> CMemoryManager<T> CMemoryManager<T>::MemoryManagerNew(T2* pNew) throw(...)
//{
// MM_RETHROW_ERRORS_START;
// CMemoryManager<T> mm;
// T* pLocal = pNew;
// mm.Attach(pLocal);
// return mm;
// MM_RETHROW_ERRORS_END("CMemoryManager::MemoryManagerNew(T* pNew)");
//}
//template<typename T, typename NewT> CMemoryManager<T>::operator CMemoryManager<NewT>& () const
//{
// NewT* pTo = dynamic_cast<NewT*>(p); // Security cast to make sure the new type in compatible with the old
// ASSERT(pTo);
// return *(CMemoryManager<NewT>*)this;
//}
//MMC_TWO(CMemoryManagerTimeCritical<T>&)
//template<typename T, typename T2> CMemoryManagerTimeCritical<T>& CMemoryManagerTimeCritical<T>::operator = (T2* p) throw(...)
//{
// CMemoryManager<T>::operator = (p);
// return *this;
//}
//template<typename T, typename T2> CMemoryManagerTimeCritical<T>& CMemoryManagerTimeCritical<T>::operator = (CMemoryManagerTimeCritical<T2>& r) throw(...)
//{
// CMemoryManager<T>::operator = (r);
// return *this;
//}
#define MMTC_TWO(return_type) template<typename T, typename T2> return_type CMemoryManagerTimeCritical<T>
Any ideas or suggestions?