Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!njin!princeton!udel!haven!umd5!terminus.umd.edu!dzoey From: dzoey@terminus.umd.edu (Joe Herman) Newsgroups: comp.lang.c Subject: Re: Help needed with MSC error 'main' > 32K Message-ID: <7616@umd5.umd.edu> Date: 21 Nov 90 14:09:21 GMT References: <20279.2749b4b0@oregon.uoregon.edu> Sender: news@umd5.umd.edu Distribution: usa Organization: University of Maryland DOSIP-CSC Lines: 74 In article <20279.2749b4b0@oregon.uoregon.edu> michelbi@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@oregon.uoregon.edu >U. of Oregon !!! GO DUCKS !!! Joe Herman U. of Maryland dzoey@terminus.umd.edu -- "Everything is wonderful until you know something about it."