Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!ames!uhccux!munnari.oz.au!bruce!merlin!tim From: tim@merlin.bhpmrl.oz (Tim Monks) Newsgroups: comp.sys.apollo Subject: cc (stack vs heap) query and another on f77 Keywords: cc, maximum stack size, f77 executable size Message-ID: <950@merlin.bhpmrl.oz> Date: 20 Jul 89 01:23:35 GMT Organization: none Lines: 65 I am trying to port some C and Fortran programs from Silicon Graphics (running Irix 3.1 ~ Sys V + enhancements) to a DN10000 under SR10.1 (BSD) and have come up with two basic problems : (i) C Consider the following C segment : #include main() { double x[1000]; x[0] = 1.00; x[999] = -1.0; fprintf(stdout,"%lf, %lf \n",x[0], x[999]); fprintf(stdout,"OK. \n"); fflush(stdout); } x is put onto the stack, so as I increase the size of this array I will get a run time error : Warning #123 Function needs ... bytes of stack which exceeds maximum stack size of 524224. I've been told that to get the array put on the heap I can either declare it as global or use malloc. I don't want to do either (mainly because the SG version doesn't need it) but also I don't want to mess around with 1D pointers when doing lots of indexing of large 2D arrays (yes I am new to C) Are there any other ways of getting around the problem ? (ii) Fortran Again a piece of code : parameter (N=1000) real*8 x(N) x(1) = 1.00 x(N) = N write(6,*) x(1), x(N) write(6,*) 'OK' end The size of the fortran binary is proportional to N !!! N Image size 1000 32 273 10000 104 305 100000 824 305 1000000 8 024 305 10000000 80 024 305 (bytes) 100000000 compiler failed What gives ? - what am I doing wrong ? -- Dr. Tim Monks Image Processing & Data Analysis Group | (direct) +61-3-566-7448 BHP Melbourne Research Laboratories | (switch) +61-3-560-7066 245 Wellington Rd, Mulgrave, 3170, | (fax) +61-3-561-6709 AUSTRALIA | (EMAIL) tim@merlin.bhpmrl.oz