Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include file loops 2

Status
Not open for further replies.

Roaders

Programmer
Aug 5, 2001
38
0
0
GB
Hi

I have a vertex class that I want to add a vector object to. I #include "vector.h" but the thing is the vector class has a vertex object in it so the vector.h file has #include "vertex.h" in so I get an infinite loop.

How do I get around this?

Thanks

Giles Giles Roadnight
messenger: giles_roadnight@hotmail.com
ICQ: 81621370
 
Use
#if !defined
#define
#endif

That should sort you out.

William
Software Engineer
ICQ No. 56047340
 
williamu shows You the right way for headers. In addition, You can write in header

class vector; //Name of Your class, defined in another header

instead

#include "vector.h"

The best way, use
#include "vector.h" etc. in *.cpp and *.c - Files only
 
You could predefine all the functions from the headers in a file compiled before, and then include both the files.

e.g.
(MainFile.cpp)
void SomeFunc(int SomeParam1, float SomeParam2);
etc

#include "SomeFile.cpp"

(SomeFile.cpp)
void SomeFunc(int SomeParam1, float SomeParam2)
{
SomeGlobalInteger = SomeParam1/SomeParam2;
return;
} MBDYProductions - "Freedome in gaming shouldn't be an extra"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top