Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LessThanJoe

Wrote a class...got some errors...help

This topic is 6014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I've never written any classes, nor have I ever had training for them, so what I'm writing here is obviously wrong...but i'm getting an error "c:\c++\tetris\tetris.h(2) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit" here is tetris.h, if you need the .cpp I can post it here, but there's a lot of it. (btw, I will go through and rename my viariables with the proper _):
  
#include <apvector.h> 

#include "tetris.cpp" 


class TETRIS
{
	public:
		// Functions

		void newshape();
		void rotate();
	
		// accessors

		apvector lefts();
		apvector rights();
		apvector bottems();
	private:
		apvector _theshape(4, 0);
		int state = 0;
                // soon to come

                // int Boardheight = 0;

                // int boardwidth = 0;


};
  
Thanks [edit: added source tags] Edited by - Magmai Kai Holmlor on January 2, 2002 8:20:40 PM

Share this post


Link to post
Share on other sites
Advertisement
First, never #include a source file in a header file, it works the other way around. You make your definitions in the header and include the header in the source.

Second you should use safe include syntax to make sure that the header file is only included once. Here is the safe include syntax:

        
#ifndef MYHEADER_H //substitute your header file name here

#define MYHEADER_H //this name can technically be anything


//but it is common practise to use the

//header file name

.
.//your definitions go here

.
#endif //#endif for #ifndef MYHEADER_H



What that error is telling you is that you recursively included a file and it just kept loading it and loading it, until it ran out of space.

---
Make it work.
Make it fast.

Edited by - CaptainJester on January 2, 2002 3:16:43 PM

Share this post


Link to post
Share on other sites
Fatal Error C1076

compiler limit : internal heap limit reached; use /Zm to specify a higher limit

The compiler ran out of storage for items that it stores in its heap. Usually this is the result of having too many symbols.

One of the following may be a solution:

-Use the /Zm compiler option to set the compiler''s memory allocation limit.

-Simplify the program:
Eliminate unnecessary include files, especially unneeded #defines and function prototypes.

-Eliminate some global variables. For instance, use a pointer to allocate memory dynamically, at run time, instead of declaring a large array.

-Eliminate unused declarations.

-Break up very large functions into smaller ones.

-Break up very large classes into smaller ones.

-Split the current file into two or more files and compile them separately.


Note If you get this error message immediately upon starting the build process, you have probably specified too high a value for /Zm, given the specific details of your program. Change the /Zm value to a lower one and re-run the build.

Share this post


Link to post
Share on other sites

Most likely you have

#include "Tetris.h" in your Tetris.cpp file

AND

#include "Tetris.cpp" in your Tetris.h file

and the compiler is going into a #include infinite loop adding each file over and over and over again..

get rid of the #include "Tetris.cpp" in you .h file and compile it again.

-

Share this post


Link to post
Share on other sites
quote:

int state = 0;



You can''t do this (really). You should make a contructor and initialize it there.

  
TETRIS::TETRIS()
{
state = 0;
}


or

  
TETRIS::TETRIS() : state( 0 )
{

}

Share this post


Link to post
Share on other sites
Well, I got rid of that error, but in it's place there are now 102 others (don't you hate when that happens?)

I've looked through about the first 50 then realized all of these are probably caused by my ingorence of classes. So I was wondering if anyone could point me to a good how-to that doesn't assume I'm an idiot.

Also, if you want to look at the class so far:

www.geocities.com/azriel182/tetris.zip

I am going to go through and add all the good stuff like comments. Also, all of those random numbers will be replaced with Boardheight and Boardwidth, but they currently assume the board is 13 spaces wide with 1 row on each side for the walls (the option of weather or not to have spaces for walls will be up for grabs with this class, but I just prefer to have them for the way I'm doing the proper rotation.)


Last thing before I go, apvector is really good (and you'll need it if your checking this is), you can find the .h and the .cpp at www.collegeboard.com > site search

Edited by - lessthanjoe on January 2, 2002 6:23:41 PM

Share this post


Link to post
Share on other sites
the include statement is like this, #include , or #include "custom path", so u can go like this incase u didnt know, #include "c:\mefiles\lib\asad.h".
you only include a file to make its definitions visible in the current scope.
you dont include a .cpp file in a header because the header has no need for it... the .cpp, however, needs the header include so it can spot all the header's definitions.
...
ur tetris is a tad overhaul - > read : trig: point rotation.
i wrote a tetris once and it looked somewhat like this:
note that this is gappy code used just to demonstrate some oop.


      
void main()
{
CTETRIS Tetris(wid,hgt);
while (Tetris.Play())
;
}//main


bool CTETRIS::Play()
{
if(!GetInput()) //getinput = false if escape was hit

return false;
else
{
if(!Shape.Act())
{ //shape has collided, check to see need to remove lines

CheckLines();
//reinitialize shape

Shape.New();
}
UpdateScreen();//draw stuffs

return true;
}
}//Play


bool CSHAPE::Act()
{
Move(GetInput());//move if arrow key (left,right,etc)

Rotate(Left); //force rotate

Move(Down); //force down

if(Dead()) return false; //has collided

return true;
}//Act



you can assume that all functions have a class member scope. this is what classes are all about!


Edited by - evilcrap on January 2, 2002 7:55:16 PM

Share this post


Link to post
Share on other sites
quote:
Original post by Midnight Coder
Fatal Error C1076

compiler limit : internal heap limit reached; use /Zm to specify a higher limit

The compiler ran out of storage for items that it stores in its heap. Usually this is the result of having too many symbols.

One of the following may be a solution:

-Use the /Zm compiler option to set the compiler''s memory allocation limit.

-Simplify the program:
Eliminate unnecessary include files, especially unneeded #defines and function prototypes.

-Eliminate some global variables. For instance, use a pointer to allocate memory dynamically, at run time, instead of declaring a large array.

-Eliminate unused declarations.

-Break up very large functions into smaller ones.

-Break up very large classes into smaller ones.

-Split the current file into two or more files and compile them separately.


Note If you get this error message immediately upon starting the build process, you have probably specified too high a value for /Zm, given the specific details of your program. Change the /Zm value to a lower one and re-run the build.




Check the source code, as it was already pointed out, it''s a recursive include problem( in that particular case that is. )



"And that''s the bottom line cause I said so!"

Cyberdrek

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

Share this post


Link to post
Share on other sites
Well, after a long time, I think I ended up at the point where I should ask this question:

Sevel .cpp files? Looks nice, but how does it work??? Doesn''t that give trouble with compiling?

Look, I now it sounds silly, but I''ve only used a single .cpp, and several header files... Worked fine for me

-Maarten Leeuwrik
"Some people when faced with the end of a journey simply decide to begin anew I guess."

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!