In my program I'm trying to set up some kind of hierarchy. A ResourceManager holds the game's resources (which includes Levels), Levels have an Update function which can add enemies to the game if certain criteria are met, and Enemies use the ResourceManager to set its image to its Sprite. So if I do a #include for each required file, I end up getting an infinite recursive include loop (Visual Studio then throws "too many include files"). Now, if I use a #pragma once (which I had no idea what it was until this day...still don't rly know what it is) I get weird compiler errors (parts of my code that used to work before now dont and now cmath and list are breaking too). How do I fix this?
EDIT: ok quick "Update:" I thought I had fixed the problem and deleted this thread; however, in my Level file if I comment out #include Enemy.h I do not get any errors; however if I uncomment it I get a plethora of weird erros:
Error 14 error C2143: syntax error : missing ';' before '{' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\cmath 20 SFML Game
Error 20 error C2143: syntax error : missing ',' before '<' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list 20 SFML Game
Error 71 error C2143: syntax error : missing ';' before 'namespace' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iostream 12 SFML Game
Now I think it's because in my ResourceManager class I have a vector of Level pointers (to store the levels). For some reason if I include Enemy in level, it breaks something. Here are the includes in Enemy, Level, and ResourceManager, if that helps:
//Level.h
#pragma once
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <vector>
#include "Enemy.h"
#ifndef LEVEL_H
#define LEVEL_H
...
//Enemy.h
#pragma once
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include "ResourceManager.h"
#include "Player.h"
...
//ResourceManager.h
#pragma once
#include <vector>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "Level.h"
Another update, I moved most of the local include files into the cpp files. It mostly has fixed it...until I need to actually put include files into headers.