0

I like really clean code so I want to pull all of the common includes into a separate file and then include that single file in all my other files. Also makes it easier if I start using a new or different library cuz I only have to change it in one place.

here is what i have in my include.h file:

#ifdef WIN32
   #define WIN32_LEAN_AND_MEAN
   #include <windows.h>
#endif

//    System Includes   //
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>

//    Imported Libraries   //
#include "xmlParser.h"

//    Our Includes   //
#include "image.h"
#include "enum.cpp"

//    OpenGL Includes   //
#include <GL/gl.h>
#include <GL/glut.h>

using namespace std;

Each file has

#include "include.h"

Simple enough.

VS2008 gives me error C1014: Too many includes. I'm pretty sure from browsing other posts that this means I'm doing recursive including. But if I do it any other way it says it can't find any of the data types that are defined in the includes.

Thanks for any help.

4
Contributors
9
Replies
10
Views
7 Years
Discussion Span
Last Post by toadzky
0

yes. it's just a cpp file (probably could be .h) that holds some enums. no actual code in it or includes

0

Yes, it should definitely be .h if it has no actual code.
Do you have include guards in your header files?

0

yes. it's just a cpp file (probably could be .h) that holds some enums. no actual code in it or includes

There is a contradiction, in your first post you say that "Each file has: #include "include.h"". If enum.cpp actually includes include.h, that results in the error you described.

[EDIT]
Assuming "Each file" refers to source files ...
[/EDIT]

0

the enum file doesn't include anything.

as for guards, i tried using them but it says that it cant find any of the types from the includes.

0

You must use include guards. Do this:

#ifndef FILENAME_H_
#define FILENAME_H_
// header code here
#endif
0

I know I should have guards. However, if I include the guards, NONE of the includes happen. It says it can't find ANY of the data types included in the guard.

0

You put the guards in the *.h files that you wrote, not the STL or other system files. If you are getting errors, then you didn't do it correctly, and you should post the header file w/guards so we can see what you did.

//"xmlParser.h"
#ifndef XMLPARSER_H
#define XMLPARSER_H
// stuff goes here

#endif
0

Can't tell you why it wasn't working the first time, because definitely tried guards before I even posted this. I gave up for a while and just focused on getting my code working. Now it's working.

Thanks for your patience and your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.