I have a simple header that contains the following:
// system.h
#pragma once
namespace System
{
void Initialize(void);
int (*Main)(int& argc, char** argv);
void Shutdown(void);
}
In "system.cpp", Initialize() is defined so that the function pointer Main(int,char**) is set to another main function which is determined by preprocessor defines to whatever system this is going to be compiled on (Windows, for now).
In the program's main.cpp, it calls the three functions above...
So when this is compiled, I get a linker error (for system.cpp) complaining that System::Main(int,char**) has already been defined in main.cpp. What's up with this?
~
// system.cpp
#include "..\system.h"
#ifdef _WINDOWS
#include "windows.h"
#else
#define SYSTEM_UNKNOWN 1
#endif
void System::Initialize(void)
{
#ifdef WINDOWS
System::Main = &Windows::Main;
#else if SYSTEM_UNKNOWN
System::Main = NULL;
#endif
}
void System::Shutdown(void)
{
System::Main = NULL;
}
I added the 'extern' keyword to the header... And still no go.