In a header file, I have a namespace that stores some extern pointers to use as global variables. This header file is then included in a few .cpp files that use its implementation. When I compile, I get the error for each global:
LNK2005 "void * Globals::gHandle" already defined in Engine.obj
How the variables are written in the header:
namespace Globals
{
extern HANDLE gHandle = nullptr;
extern void* processBaseAddress = nullptr;
extern void* smBaseAddress = nullptr;
}
The header file is using #ifndef so I shouldn't be included more than once. Some functions either get or set the values of these global variables.