I have a debug condition to manage memory where I have
extern void* operator new(unsigned int size, const char* file, int line);
extern void operator delete(void* address, const char* file, int line);
extern void Delete(void* address);
#define FUN_NEW new(__FILE__, __LINE__)
#define FUN_DELETE delete
This exists in Memory.h and is implemented in Memory.cpp. Memory.h is defined as:
#ifdef MEMORY_EXPORT
#define DECL_MEMORY __declspec(dllexport)
#else
#define DECL_MEMORY __declspec(dllimport)
#endif
class DECL_MEMORY Memory : public Singleton<Memory>
{
Now, I have SoundStuff.h and SoundStuff.cpp, which are in a seperate project, also being converted to a dll in a similar manner to above. The project that SoundStuff
belongs to has a project dependency to the project that Memory
belongs to. In the implementation of SoundStuff.cpp, FUN_DELETE
, from Memory.h, is called. It is called through a function in a separate project, but it is called regardless. This is leading to linker errors.
error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,char const *,int)" (??3@YAXPAXPBDH@Z) referenced in function __unwindfunclet$?Init@SoundStuff@@AAEXXZ$1 SoundStuff.obj
Why is this and how can I fix it?