If I do this, I get a compiler error in main.cpp saying `gStateStack' undeclared (first use this function).
// GameStates.h
#include <stack>
struct gStateStruct { void (*StatePointer)(); };
std::stack<gStateStruct> gStateStack;
// main.cpp
#include <stack>
#include "GameStates.h"
using namespace std;
int main(int argc, char **argv)
{
Init();
// Game loop.
while(!gStateStack.empty())
{
gStateStack.top().StatePointer(); // ERROR
}
Shutdown();
return 0;
}
I don't understand. By including GameStates.h, shouldn't it be declaring gStateStack in main.cpp?
Edit: Oh yeah, externs. I got everything to compile by using 'extern std::stack gStateStack;' in main.cpp but then I got a linker error.