I am getting sick with this error, function Redefinition !!! .
I am building a log file, So that i can keep track of my program memroy allocation and deallocation,
to get rid of memory leaks.For that i have build a function template in a Namespace. What i am doing is that , i will pass
Object to this function, the object could be of any type, and getting information about that Object.
// MemTrack.h
#ifndef MEMTRACK_H
#define MEMTRACK_H
#include <f32file.h>
namespace MemTracker
{
void LogInit(const char* logName = NULL)
{
//Doing Something with logName
}
template<class T>
void MemLog( T* mVar )
{
// Doing something with mVar
}
};
#endif
Now when i include this MemTrack.h in one file it is fine
// Myclass.cpp
#include "MemTrack.h"
MyClass::MyClass()
{
MemTracker::MemLog(this); //Working fine , no error
}
But when i include this MemTrack.h file in another file(s) it give me error given below
error LNK2005: "void __cdecl MemTracker::LogInit(char const *)" (?LogInit@MemTracker@@YAXPBD@Z) already defined in
SEARCHFILECONTAINER.obj
PLease help me , and tell me how could i able to get access this function in multiple files.
..... Thanks in advance
with best regards
chetan





