0

I've changed one of my classes adding a method and some includes, after doing this I'm getting a lot of undefined or missing errors for things that haven't problems and worked well until then.
This is the header file where I get the error:

assetloader.h

#ifndef LS_ASSETLOADER_H
#define LS_ASSETLOADER_H
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/types.h>

#include <glm/glm.hpp>
#include <vector>

//these are the headers that give me problems
//#include "scene.h" 
//#include "model.h"



//the 2 methods below are commented so i don't get errors for missing Scene
class AssetLoader {
    //void importScene(aiNode* node, ls::Scene* scene, const aiScene* aScene);

public:
    bool loadMesh(
        const char* path,
        std::vector<glm::vec3>* vertices,
        std::vector<glm::vec3>* normals,
        std::vector<glm::vec2>* uvs
    );

//  bool loadScene(const char* path, ls::Scene* scene);
};

#endif

these other two are the scene and model headers:

scene.h

#ifndef LS_SCENE_H
#define LS_SCENE_H
#include <vector>
#include "camera.hpp"
#include "light.h"
#include "model.h"

namespace ls {
    class Scene;
}

class ls::Scene {
    std::vector<Camera*> _camera;
    std::vector<Light*> _light;
    std::vector<Model*> _model;

    unsigned int _activeCamera;

public:
    Scene();

    void addCamera(Camera* camera);
    void addLight(Light* light);
    void addModel(Model* model);

    void draw();
};

#endif

model.h

#ifndef LS_MODEL_H
#define LS_MODEL_H
#include "mesh.h"
#include "material.h"
#include "renderer.h"
#include <glm/glm.hpp>

class Model {

    Mesh* _mesh;
    Material* _material;
    Renderer* _renderer;

    glm::mat4 _transform;

public:
    Model(Mesh* mesh, Material* material);
    Renderer* renderer() const;
    glm::mat4 transform() const;

    void setPosition(glm::vec3 position);
    void translate(glm::vec3 translation);
    void scale(glm::vec3 factor);
    void setRotation(glm::vec3 axis, float angle);
};

#endif

mesh.h

#ifndef LS_MESH_H
#define LS_MESH_H
#include <vector>
#include <glm/glm.hpp>
#include "assetloader.h"
#include "texture2D.h"

class Mesh {
    std::vector<glm::vec3> _vertices;
    std::vector<glm::vec3> _normals;
    std::vector<glm::vec2> _uvs;

public:
    Mesh(const char* path);
    Mesh();

    int numVertices() const;
    std::vector<glm::vec3> vertices() const;
    void setVertices(std::vector<glm::vec3> vertices);
    std::vector<glm::vec2> uvs() const;
    void setUVs(std::vector<glm::vec2> uvs);
    void setNormals(std::vector<glm::vec3> normals);
    std::vector<glm::vec3> normals() const;


};

#endif

I have not included the .cpp files cause i don't think is there the problem (I haven't modified them from last time they worked).
Here are some samples of the error i get (i haven't included all of them cause they are too much and are similar to these ones):

1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(10): error C2143: syntax error : missing ';' before '*'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(17): error C2061: syntax error : identifier 'Mesh'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(18): error C2143: syntax error : missing ';' before '*'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
ChiP
  • 313
  • 1
  • 2
  • 9
  • Does `scene.h` or `model.h` indirectly `#include` the `assetloader.h` header? – Andy Prowl May 02 '13 at 18:25
  • I've included the mesh.h header, it seems that I include assetloader.h there and then model.h includes mesh.h, can this be the problem? – ChiP May 02 '13 at 18:58
  • 1
    Indeed, it is. It is all explained [here](http://stackoverflow.com/questions/14909997/why-arent-my-include-guards-preventing-recursive-inclusion-and-multiple-symbol) (first question/answer) – Andy Prowl May 02 '13 at 18:59
  • thanks for the link, making a forward declaration seems to solve the problem but now i get an other message(maybe i did not understand well where to use it). I've deleted the #include "assetLoader.h" in mesh.h and added class AssetLoader; but now I get the following message: `assetloader.obj : error LNK2019: unresolved external symbol "public: __thiscall Mesh::Mesh(void)" (??0Mesh@@QAE@XZ) referenced in function "private: void __thiscall AssetLoader::importScene(struct aiNode *,class Scene *,struct aiScene const *)" (?importScene@AssetLoader@@AAEXPAUaiNode@@PAVScene@@PBUaiScene@@@Z)` – ChiP May 02 '13 at 21:20
  • as if the program don't know mesh, even if I include it in the assetloader file – ChiP May 02 '13 at 21:24

1 Answers1

0

Looks like you have included model.h in mesh.h
You need to forward declare Mesh in model.h

class Mesh;
class Model {
alexrider
  • 4,449
  • 1
  • 17
  • 27