I keep getting a linking error for certain functions. Here's one:
It's a template specialization, so it should reside in two headers.Code:Error 8 :StrTraits<char>::GetLength(char const *)" (?GetLength@?$StrTraits@D@Strings@@SAIPBD@Z) already defined in Help.obj Help2.obj
But as I include the header in two or more .cpp files, I get a linking error. Maybe someone can shed some light?
Definition is as follows:
(Yes, I know it's the wrong way to do traits, but I'm going to change it later.)Code:Code:template<typename T> class StrTraits { public: typedef int (fnc_tprintf_s)(T* buffer, size_t sizeOfBuffer, const T* format, ...); typedef int (fnc_tvprintf_s)(T* buffer, size_t sizeOfBuffer, const T* format, va_list argptr); typedef int (fnc_tvcprintf)(const T* format, va_list argptr); typedef int (fnc_tcscmp)(const T* string1, const T* string2); static const T* UINT64_T_IDENTIFIER; static const T* INT64_T_IDENTIFIER; static const T* LONG_IDENTIFIER; static uint32_t GetLength(const T* strData); static fnc_tprintf_s* GetFormatFunction(const T*); static fnc_tvprintf_s* GetVFormatFunction(const T*); static fnc_tvcprintf* GetVFormatCountFunction(const T*); static fnc_tcscmp* GetCompareFunction(const T*); static T* Allocate(uint32_t nSize); static void Delete(T* pToDelete); }; template<> uint32_t StrTraits<char>::GetLength(const char* strData) { return strlen(strData); } template<> uint32_t StrTraits<wchar_t>::GetLength(const wchar_t* strData) { return wcslen(strData); }



LinkBack URL
About LinkBacks




CornedBee