Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Massive errors on #include, what's wrong with this class?

Avatar of Snapples
Snapples asked on
Visual C++.NETEditors IDEs
3 Comments1 Solution267 ViewsLast Modified:
Hello all,

I'm actually looking for an explanation more than a solution, as I know how to work around the problem but I don't know why I'm getting these errors, as far as I see it I shouldn't be getting them at.

This is a DirectX10 application but the errors aren't related to DX. I have a class called Renderer which I use to draw primitive shapes such as lines, grids, spheres, etc. Each of these is an object in Renderer. It's a singleton class and has to be accessable everywhere.
I have included it to my main class's header and that works fine, however when I try to include Renderer.h to any other header file I get tons of syntax and missing type specifier errors on the shape objects, as if I haven't included their header files, but I have.

I get these 3 errors per shape object.
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

My first idea would be missing include guards, but all my header files have #pragma once.
I can fix the problem with forward class declaration on the shape objects but it still doesn't make sense why I'm getting those errors in the first place.


I'd like to know what's causing this so I can avoid it in the future.
Thanks in advance.


// ********************
// Renderer.h
// ********************

#pragma once

// Helper.h: includes all DirectX related headers
#include "Helper.h"

// The shape classes
#include "Line.h"
#include "Quad.h"
#include "Sphere.h"
#include "Axis.h"
#include "Grid.h"


// Defines the singleton for easy calling
#define RENDERER (Renderer::GetSingleton())

// Defines for current mode * See SetMode()
#define MODE_EDIT_GROUND						2
#define MODE_EDIT_FRONT							4
#define MODE_EDIT_SIDE							8
#define MODE_EDIT_AXIS							16
#define MODE_EDIT_NONE							32

// Forward declarations, fixes the problem when uncommented
// But they're already included so why need these??
//class Line;
//class Quad;
//class Sphere;
//class Axis;
//class Grid;

class Renderer
{
public:

	static Renderer* GetSingleton();
	virtual ~Renderer(void);

	void Initialize();

	void DrawLine(D3DXVECTOR3 point1,D3DXVECTOR3 point2, D3DXCOLOR color);

	void DrawQuad(D3DXVECTOR3 point1,D3DXVECTOR3 point2,D3DXVECTOR3 point3,D3DXVECTOR3 point4,D3DXCOLOR color);

	void DrawSphere(D3DXVECTOR3 center, float radius, D3DXCOLOR color);

	void DrawCube(D3DXVECTOR3 v1, D3DXVECTOR3 v2, D3DXVECTOR3 v3, D3DXVECTOR3 v4, D3DXVECTOR3 v5, D3DXVECTOR3 v6,
				  D3DXVECTOR3 v7, D3DXVECTOR3 v8, D3DXCOLOR color);


	void Draw();

	void Update();

	void SetMode(DWORD flags);

protected:

	
private:
	// Private constructor
	Renderer(void);
	static Renderer* m_pRenderer;
 
        // 3 ERRORS on each of these 7 lines
	Line*		m_Line;
	Quad*		m_Quad;
	Sphere*		m_Sphere;
	Axis*		m_Axis;
	Grid*		m_GroundGrid;
	Grid*		m_XYGrid;
	Grid*		m_ZYGrid;

	DWORD		m_ModeFlags;
	bool		m_bDebug;


private:
	Renderer(const Renderer& t);
	Renderer& operator=(const Renderer& t);

};
ASKER CERTIFIED SOLUTION
Avatar of pgnatyuk
pgnatyukFlag of Israel image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers