So, I have game.hpp and game.cpp
Game.hpp:
#ifndef __GAME_HPP__
#define __GAME_HPP__
#include <list>
#include <string>
#include <mutex>
#include <SFML/Window.hpp>
namespace gm{
// Bunch of class definitions, et al.
}
#endif
And here's game.cpp
#include <cstdlib>
#include <iostream>
#include <memory>
#include <thread>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include "game.hpp"
using namespace gm;
// Bunch of class implementations and int main.
If I compile this code with g++ game.cpp -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network -lsfml-pthread it works absolutely fine, and I get a nice executable.
But now I have two other files: testCage.hpp and testCage.cpp.
testCage.hpp:
#ifndef __TEST_CAGE__
#define __TEST_CAGE__
#include <map>
#include <SFML/Window.hpp>
#include "game.hpp"
class TestEntity : public gm::Entity{
public:
TestEntity():Entity(gm::EntityType::NULL_TYPE){};
void testFoo(int m);
};
#endif
testCage.cpp:
#include "testCage.hpp"
void TestEntity::testFoo(int m){
m += 1; // some garbage statement.
};
If I THEN try to compile and link both files with g++ game.cpp testCage.cpp -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network -lsfml-pthread
I get error: ‘RenderWindow’ in namespace ‘sf’ does not name a type in file included from testCage.hpp(e.g. game.hpp).
Even though testCage is just some test code, the architecture is worth mentioning. Everything in game.hpp is completely self-contained, and will never require any other locally developed header files. So, for example, game.hpp will never have a line like include "someCageHeader.hpp". Likewise, all cage headers should have ONLY "game.hpp" as their sole dependency, and will never include each other. Also likewise, all cage headers are perfectly self-contained in themselves, and the only file that mixes and matches calls to functions and classes defined in multiple different headers is in "game.cpp". This is the ONLY file that actually needs to include multiple cageHeader files.
Beyond that, I'm stumped. What's going on here? Any information that could help me figure out why trying to set things up this way is causing this error for me?
Thank you very much for your time.