-
#include nesting level?
I'm working on a fairly large project, and in an effort to be moderately organized, I'm placing every class, every part, in a seperate .cpp/.h pair. Needless to say, since each part needs several of the others, this leads to a large amount of #Include's.
I've had no problems with this, until today, when modifying one specific part required the adding of a couple more #includes. Now, I'm suddenly getting a bunch of the following errors:
warning C4182: #include nesting level is 362 deep; possible infinite recursion
and
fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
Is there a limit to the number of #includes that can be used in any given project? What is this internal heap limit, and is this /Zm?
-
You have a header file which includes a header file which includes the
first header file.
-
The best way around that is put conditional defines in your .h files :
Code:
#ifdef __HFILENAME__ //or some unique name to the .h file
#define __HFILENAME__
all you .h stuff....
#endif
What happens on the first time this .h file is included __HFILENAME__ is not defined so it defines it and includes everything from there until the #endif. The next time this file is included __HFILENAME__ is defined so that code is ignored. This will keep your .h files from running over each other.