Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!hobbes.physics.uiowa.edu!ns-mx!tessa!colburn From: colburn@tessa (alex colburn) Newsgroups: comp.os.msdos.programmer Subject: Re: Porting software to the PC, 64K data structure barrier. Keywords: PC, 64K struct size limitations, MSDOS Message-ID: <6746@ns-mx.uiowa.edu> Date: 30 Jun 91 03:34:35 GMT References: <1972@contex.contex.com> <1991Jun29.203704.8443@uwasa.fi> Sender: news@ns-mx.uiowa.edu Organization: University of Iowa, Image Analysis Facility Lines: 43 In article <1991Jun29.203704.8443@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes: >In article <1972@contex.contex.com> avinash@felix.contex.com (Avinash Chopde) writes: >>I need to port a program I wrote for UNIX machines onto the IBM PC. >>I have the Turbo C++ compiler, and at first, I just tried to >>recompile all the sources, but the compiler complained about >>a struct being greater than 64K in size! >>Now, I'm sure I'm doing something wrong, surely there must be some >>way of defining large arrays. >>Is there ? >: > >I've only used Turbo Pascal, so this is just a tentative answer. In >TP one has to go around the 64K limitation by a judicious use of >pointers (I have a FAQ collection to cover how). But doesn't Turbo >C have what is called a huge model (a rhetorical question). With a huge model you may have static data total more than 64k BUT each module must have less than 64k. Also any pointer to a data structure larger than 64k must be explcitly declared as huge char huge *ptr. If you don't do this a reference like ptr[64k + x] will only try to increment the offset and not the segment of the address. A real pain in the ass, and usually resulting in a reboot. even if you do declare everything as huge, you still have to watch out for things like fread which expect a far pointer in the huge memory model. I called Borland and it is a bit confusing, even though they have something called a huge memory model, this model doesn't implicitly convert all pointers to huge. So fread can only handle 64k chunks of data at a time. My solution to all of this is to buy a new compiler. Borland isn't going to offer a 32 bit compiler until the OS2 version. At the moment I'm looking into Zortech's new 32 compiler with DOS extenders. It is my impression that this should make all of my memory allocation problems imposed by DOS much less of a hassle. Allocation of > 64k to the size of all system memory should be completely transparent. Does anyone have experience with DOS extenders and 32 bit compilers? I'd like to hear any info on the subject. Alex.