mercredi 7 novembre 2018

Cannot include h files with each other [duplicate]

This question already has an answer here:

I have the problem that the file States.h doesn't know the enum "ExecutionStates" although it's included.

States.h:

#ifndef States_h
#define States_h

#include "Definitions.h"

class States
{
    public:
        void StateRun();
        void InjectState(ExecutionStates injected);    
    private:
        ExecutionStates currentState;
};
#endif 

Definitions.h:

#ifndef Definitions_h
#define Definitions_h        
#include "States.h" //this gives error

enum ExecutionStates {
    EXS_Idle [and more]
};
#endif

When I include States.h in Definitions.h the error occurs in States.h and says that ExecutionStates does not name a type. I tried to forward declare the enum in States.h, but it didn't help. THank you in advance.

Aucun commentaire:

Enregistrer un commentaire