Include files

Started by
8 comments, last by Jedimace 15 years, 5 months ago
Something is wrong when I try to include my include files. I include the .h file of the class I want to include, but it's not sensing the class inside. It is not that it says the file does not exist, but it says that the class in the file is not defined. Here is my code for my class that takes the parameter:
#ifndef RENDERER_H_INCLUDED
#define RENDERER_H_INCLUDED

#include "Orange 3d/system/MemoryManager.h"
#include "Orange 3d/graphics/Object.h"
#include <GL/SDL.h>
#include <GL/SDL_opengl.h>

enum driver_t {OpenGL,Null,Direct3d10,Direct3d9};

class Renderer : MemoryObject {
private:
    driver_t rendererDriver;
public:
    Renderer(driver_t driver);
    void prepareRender();
    void draw(Object obj);
    void endRender();
    ~Renderer();
};

#endif // RENDERER_H_INCLUDED
And here is the class it includes:
#ifndef OBJECT_H_INCLUDED
#define OBJECT_H_INCLUDED

#include <list>
#include "Orange 3D/system/MemoryManager.h"
#include "Orange 3D/math/Vector3f.h"
#include "Orange 3D/math/Vector2f.h"
#include "Orange 3D/math/Rgba.h"
#include "Orange 3D/graphics/Texture.h"

typedef class Obj : MemoryObject {
    static std::list<Vector3f> vertices;
    static std::list<Vector3f> indices;
    static std::list<Rgba> colors;
    static std::list<Vector3f> normals;
    static std::list<Vector2f> texcoords;
    int texid;
    Vector3f* position;
    Vector3f* rotation;
    Vector3f* scale;
public:
    void setVertices(std::list<Vector3f> vertex, std::list<Vector3f> index, std::list<Rgba> color, std::list<Vector3f> normal, std::list<Vector2f> texcoord);
    void setTexture(int textureId);
    void setPosition(Vector3f* position);
    void setRotation(Vector3f* rotation);
    void setScale(Vector3f* scale);
    Obj(std::list<Vector3f> vertex, std::list<Vector3f> index, std::list<Rgba> color, std::list<Vector3f> normal, std::list<Vector2f> texcoord, int textureId);
    ~Obj();
};

typedef Obj Object;

#endif // OBJECT_H_INCLUDED
I don't know what is wrong with it. All my other classes doing the same thing work.
-Jedimace1My company siteEmber StudiosAlmost Done
Advertisement
Quote:Original post by Jedimace
typedef class Obj : MemoryObject {

This typedef looks fishy.
I have already tried it without the typedefs. Same thing happens.
-Jedimace1My company siteEmber StudiosAlmost Done
GCC Error:
..\..\..\src\Orange 3d\graphics\Renderer.h|17|error: `Obj' has not been declared|..\..\..\src\Orange 3d\graphics\Renderer.h|17|error: ISO C++ forbids declaration of `obj' with no type|||=== Build finished: 2 errors, 0 warnings ===|
-Jedimace1My company siteEmber StudiosAlmost Done
Quote:Original post by Jedimace
I have already tried it without the typedefs.

Why are you using the plural here? Only the first typedef is wrong. The second is "necessary". If you remove that too, Object is a variable of type Obj, not a type synonyme.

Please remove only the first occurrence of typedef and tell us what you get.
It sounds a lot like you've got a circular include problem going on. Did you try using a forward declaration?
Quote:Original post by SiCrane
It sounds a lot like you've got a circular include problem going on. Did you try using a forward declaration?

You mean class Object;? I don't believe that would work here, because for whatever reason he is passing Objects by value:
void draw(Object obj);
Quote:Original post by DevFred
Quote:Original post by Jedimace
I have already tried it without the typedefs.

Why are you using the plural here? Only the first typedef is wrong. The second is "necessary". If you remove that too, Object is a variable of type Obj, not a type synonyme.

Please remove only the first occurrence of typedef and tell us what you get.


Nothing.

SiCrane: Solution! Thanks!
-Jedimace1My company siteEmber StudiosAlmost Done
Forward declarations are sufficient for declaring a function that takes an object parameter by value. You do need the complete definition to call the function though.
Quote:Original post by SiCrane
Forward declarations are sufficient for declaring a function that takes an object parameter by value. You do need the complete definition to call the function though.


Ok.
-Jedimace1My company siteEmber StudiosAlmost Done

This topic is closed to new replies.

Advertisement