Xref: utzoo comp.lang.c:15616 comp.sys.ibm.pc:23408 Newsgroups: comp.lang.c,comp.sys.ibm.pc Path: utzoo!utgpu!jarvis.csri.toronto.edu!ephemeral.ai.toronto.edu!bradb From: bradb@ai.toronto.edu (Brad Brown) Subject: Re: new Quick C "2" ? Message-ID: <89Jan19.160509est.11046@ephemeral.ai.toronto.edu> Organization: Department of Computer Science, University of Toronto References: <2759@skivs.UUCP> <923@ubu.warwick.UUCP> Date: Thu, 19 Jan 89 16:05:03 EST In article <923@ubu.warwick.UUCP> geoff@emerald.UUCP (Geoff Rimmer) writes: > >The problems I have found with QuickC (1.00 and 1.01) are : > >... >(c) my C program is constantly too big for 'link' - when the object >files are linked together, I frequently get the error "Stack plus data >exceed 64K". The only way I have found of getting around this problem >is to take out several functions in my code (usually functions that I >*want* in the program, but don't 100% *need* ). However, soon, it is >going to come to a point when I am only left with essential functions >and I am going to have big problems! >... >I am using a DELL 200 series 640K RAM, and am compiling in large >memory model. The problem you describe is not a bug in the compiler. You are declaring large amounts of data as static or declaring many large variables to be global to a module. The solution is to make some stuff auto (which doesn't solve very much because you need to keep the stack size down) or to dynamically allocate it (which is the smart way to do it.) The problem is that all memory models for that compiler need to have global data and stack in one (64k max) stack. For instance, you must have some modules that look like this: --------- Top of file int bigArray[10000]; void foo() { /* Do some stuff with bigArray */ ... } --------- which you should change to look like --------- Top of file int * bigArray_p; void foo() { /* Allocate (zero-initialized) memory for bigArray */ bigArray_p = (int *)calloc( 10000, sizeof( int ) ); if ( bigArray_p == NULL ) dieHoribleDeath(); /* Do some stuff with bigArray */ ... } --------- See, the second way allocates space for bigArray on the heap, where there is lots of memory, and the linker won't grumble any more. Besides, doing things this way will lead to better programming style because it will be easier to manipulate data and pass it from module to module. (-: Brad Brown :-) bradb@ai.toronto.edu