Reputation: 307
Everything was going well until I added the drow function into Renderer.h file
void Drow(const VertexArray& va, const IndexBuffer& ib, const Shader& shader)const;
Renderer.h :
#include <GL\glew.h>
#include"Shader.h"
#include"VertexArray.h"
#include"IndexBuffer.h"
#define ASSERT(x) if(!(x))__debugbreak();
#define GLCall(x) GLClearError();\
x;\
ASSERT(GLlogCall(#x, __FILE__, __LINE__))
/*function to clear all last errors in opengl*/
void GLClearError();
/*function to print all errors */
bool GLlogCall(const char* function, const char* file, int line);
class Renderer {
public:
void clear()const;
void Drow(const VertexArray& va, const IndexBuffer& ib, const Shader& shader)const;
};
When I try to build it I get this error in visual studio 2015 :
Error C2143 syntax error: missing ',' before '&'
and this one
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
I could not figure out why !
Upvotes: 0
Views: 463
Reputation: 307
the problem was that VertexArray, IndexBuffer or Shader header files were including Rendered.h file so I had circular dependencies like this :
Renderer.h
#include"Shader.h"
#include"VertexBuffer.h"
#include"IndexBuffer.h"
class Renderer{
public:
// some code
void Drow(const VertexArray& va, const IndexBuffer& ib, const Shader& shader)const;
}
and Shader.h ,VertexBuffer.h,IndexBuffer.h files have this code:
#include"Renderer.h"
class className{
// code
}
so I used the forward declaration and included the headers to cpp file and files have become this way Renderer.h
#include <GL\glew.h>
class Shader.h;
class VertexBuffer.h;
class IndexBuffer.h;
class Renderer{
public:
// code
void Drow(const VertexArray& va, const IndexBuffer& ib, const Shader& shader)const;
}
Renderer.cpp
#include "Renderer.h"
#include<iostream>
#include"Shader.h"
#include"VertexArray.h"
#include"IndexBuffer.h"
// the rest of code
and Shader.h ,VertexBuffer.h,IndexBuffer.h files have this code:
//still have
#include "Renderer.h"
class className{
// code
}
Upvotes: 1