I'm getting a weird error involving my memory initializer function that is in the namespace mem. The error is thus:
1>------ Build started: Project: EEngine - Editor, Configuration: Debug Win32 ------
1>Build started 2/3/2013 2:02:06 PM.
1>InitializeBuildStatus:
1> Touching "Debug\EEngine - Editor.unsuccessfulbuild".
1>ClCompile:
1> E_Memory.cpp
1>ResourceCompile:
1> All outputs are up-to-date.
1>Link:
1> Creating library C:\Games\!Echoes Team\EEngine - Editor\Debug\EEngine - Editor.lib and object C:\Games\!Echoes Team\EEngine - Editor\Debug\EEngine - Editor.exp
1>E_Engine.obj : error LNK2019: unresolved external symbol "void __cdecl mem::initializeMemory(void)" (?initializeMemory@mem@@YAXXZ) referenced in function "public: __thiscall EEngine::Engine::Engine(void)" (??0Engine@EEngine@@QAE@XZ)
1>C:\Games\!Echoes Team\EEngine - Editor\Debug\EEngine - Editor.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.12
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any help would be greatly appreciated.
E_Memory.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#ifndef _MEMORY_HEAP_
#define _MEMORY_HEAP_
#define _MEMORY_SIZE_ 100
using namespace std;
namespace mem
{
void initializeMemory();
void* operator new(size_t size);
void operator delete(void* ptr);
}
class memoryManager
{
public:
memoryManager();
~memoryManager();
void* retrieve(int size);
private:
void* m_heap[_MEMORY_SIZE_];
};
#endif
|
E_Memory.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include "E_Memory.h"
#include <iostream>
using namespace mem;
using namespace std;
memoryManager* heap;
memoryManager::memoryManager()
{
for(int i = 0; i < _MEMORY_SIZE_; i++)
{
m_heap[i] = malloc(sizeof(void*));
}
}
void* memoryManager::retrieve(int size)
{
void* ptr;
ptr = malloc(size);
return ptr;
}
void initializeMemory()
{
#ifndef _MEMORY_INITIALIZED_
#define _MEMORY_INITIALIZED_
heap = new memoryManager;
#endif
}
void* operator new(size_t size)
{
void* ptr;
ptr = heap->retrieve(size);
cout<<"testing";
return(ptr);
}
void operator delete(void* ptr)
{
}
|
E_Engine.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#ifndef _ENGINE_H_
#define _ENGINE_H_
#ifdef _RELEASE
#define WIN_32_LEAN_AND_MEAN
#endif
//#include "GameLayer.h"
#include "E_Core.h"
#include "common_header.h"
#include "E_Window.h"
using mem::initializeMemory;
namespace EEngine
{
class Engine
{
public:
Engine();
~Engine();
Core* core;
private:
std::string logName;
};
}
#endif
|
E_Engine.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include "E_Engine.h"
using namespace EEngine;
Engine::Engine()
{
initializeMemory();
logName = "log.txt";
LogMgr::createLog(logName);
core = new Core();
}
Engine::~Engine()
{
if(core) delete core;
}
|