Help needed with MSC error 'main' > 32K

Joe Herman dzoey at terminus.umd.edu
Thu Nov 22 01:09:21 AEST 1990


In article <20279.2749b4b0 at oregon.uoregon.edu> michelbi at oregon.uoregon.edu writes:
>
> 
>I am having trouble with a fatal compilation error in Microsoft C 6.0 and
>QuickC 2.5.  The error message is as follows:
> 
>    fatal error C1126: 'main' : automatic allocation exceeds 32K
> 
>The only unusual thing that I can see with my main is the size of 4 arrays,
>each having 5000 float elements.  If I declare these arrays global to the
>program (ie before 'main()' declaration) the program will compile just fine.


It sounds like you're doing something like this:

main (int argc, char **argv)
{
  float foo[5000];
  floot bar[5000];

	...
}

You probably don't want those arrays to be automatic.  Try moving them outside
the declaration of main where they'll be global and in your data segment.



float foo[5000], bar[5000];
main (int argc, char **argv);
{
	...
}


If you want these arrays to only be accessable by main() make
the declarations static.  e.g.

main (int argc, char **argv)
{
  static float foo[5000];
  static float bar[5000];

      	...
}

The reason for the error is that automatic vars are placed on the
stack and apparently the compiler won't place more than 32K onto the
stack (though I'm not sure why the limit is 32k instead of 64k).  Why
do four 5000 element arrays take up > 32K instead of 20k?  Because a
float is 4(?) bytes.  You'll also have to change models to medium (or
is it compatct) which uses small code pointers and large data
pointers.

> 
>Michel
> 
> 
>/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
>Michel Biedermann           michelbi at oregon.uoregon.edu
>U. of Oregon                !!! GO DUCKS !!!


			Joe Herman
		

			U. of Maryland

dzoey at terminus.umd.edu



-- 
"Everything is wonderful until you know something about it."



More information about the Comp.lang.c mailing list