Skip to main content
gamedev.net
🔒 Locked

Some Header Issues

Started by KuroKitten 0 replies 1k views
Original Post
KuroKitten
KuroKitten
I'm pretty sure I know what the issue is, though I could be wrong. My headers seem to be conflicting with each other. I have two custom classes so far, both defined in seperate files. In one class's header I include the other custom class, and I also include it in my main file. I can remove any inclusion and the problem is fixed, but I wanted to know the cleanest and best way to organize my header inclusions. The files are as such: main.cpp

#include <cstdlib>
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include "GameMap.h"
#include "Texture.h"
GameMap.cpp

#include "GameMap.h"
GameMap.h

#include <cstdlib>
#include <iostream>
#include <cstdarg>
#include "Texture.h"
Texture.cpp

#include "Texture.h"
Texture.h

no includes
That's the general strcture. Thanks in advance for any and all help ^^ Meow
wolfenstein
wolfenstein
Did you enclose your header file definitions with pre-processor directives to ensure that they only get included once?

For example in Texture.h you should have

#ifndef _TEXTURE_H_
#define _TEXTURE_H_

// The rest of the code goes here

#endif

Do the same thing in every header file but replace _TEXTURE_H_ with the appropriate file name
"Segata Sanshiro!!!"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.