home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.msdos.programmer
- Path: sparky!uunet!sun-barr!decwrl!csus.edu!netcomsv!mork!resnicks
- From: resnicks@netcom.com (Steve Resnick)
- Subject: Re: far struct - how to do it ?
- Message-ID: <czpmbhl.resnicks@netcom.com>
- Date: Thu, 30 Jul 92 16:58:30 GMT
- Organization: What? Me organized? You should see my checkbook!
- References: <1992Jul29.125835.14342@msc.cornell.edu>
- Distribution: comp.os.msdos.programmer
- Lines: 124
-
- In article <1992Jul29.125835.14342@msc.cornell.edu> revesz@msc.cornell.edu (Peter Revesz) writes:
- >Hi, Netters,
- >
- >My global data is basicly in structures. To avoid
- >compile-time error message (global data >64 Kb) I have
- >to make all global far.
- >
- >How to make a struct far?
- >
- >This way:
- >
- >struct one {
- > int far a[100];
- > double far b[2000];
- >} one;
- >
- >or this way:
- >
- >struct two {
- > int a[100];
- > double b[2000];
- >} far two;
- >
- >
- >or this way?
- >
- >struct three {
- > int far a[100];
- > double far b[2000];
- >} far three;
- >
- >
- >Which the proper way to create far structs?
- >Any help will be appreciated.
- >
- >Peter Revesz
- >
- >revesz@msc.cornell.edu
-
- > Hi, Netters,
- >
- > My global data is basicly in structures. To avoid
- > compile-time error message (global data >64 Kb) I have
- > to make all global far.
- >
- > How to make a struct far?
- >
- > This way:
- >
- > struct one {
- > int far a[100];
- > double far b[2000];
- > } one;
- >
- This won't work - the data being delcared is static, which will still
- result in the same error message.
-
- > or this way:
- >
- > struct two {
- > int a[100];
- > double b[2000];
- > } far two;
- >
- >
- > or this way?
- >
- > struct three {
- > int far a[100];
- > double far b[2000];
- > } far three;
- >
- >
- > Which the proper way to create far structs?
- > Any help will be appreciated.
- >
-
- How about:
-
- struct foo {
- int *a;
- double *b;
- } bar;
- .
- .
- .
- if ((bar.a = calloc(sizeof(int),100)) == NULL)
- .
- .
- .
- if ((bar.b = calloc(sizeof(double),2000)) == NULL)
- .
- .
- .
-
-
- For one thing the far keyword is not portable, and is implementation dependant.
- the meathod I have showed you is portable, and will work with ANSI C.
-
-
- In 8086 real mode and 80286 protected mode, the processor's maximum memory
- allocation unit is a 64K segment. (except in huge model where the compiler
- generates the code necessary to 'tile' segments). When you compile your code,
- static data goes in a single segment, DGROUP. If, at compile time, the static
- data consists of pointers rather than the actual arrays, then the DGROUP
- is smaller. If you are compiling under medium or large memory models,
- you can allocate almost 64K per item, provided there is enough available
- memory on the far heap. If you are using the compact, or small models,
- you can add the far keyword in front of your pointer declarations and use
- farcalloc (or farmalloc) to get memory.
-
-
-
- Hope this helps ....
-
-
- Steve
-
- --
- ------------------------------------------------------------------------------
- Steve Resnick - resnicks@netcom.com steve@axebbs.kludge.com FidoNet: 1:143/105
- "I just want to be the one you run to, I just want to be the one you come to.
- I just want to be there for someone, when the night comes" - J. Cocker
- -----------------------------------------------------------------------------
-