home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.msdos.programmer
- Path: sparky!uunet!mcsun!sunic!dkuug!daimi!aau!psykseth
- From: psykseth@aau.dk (Seth Chaiklin)
- Subject: GLOBAL structs > 64K
- Message-ID: <1993Jan12.115830.1043@aau.dk>
- Organization: Aarhus University, Denmark
- Date: Tue, 12 Jan 1993 11:58:30 GMT
- Lines: 50
-
- Harvey Shulman posted the following code for making a structure that was
- greater than 64K: (thanks Harvey!)
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <alloc.h>
-
- void main()
- {
- int i;
- typedef struct yynew {int current, advance;} yynew;
- yynew *yycrank, j;
-
- /* in the allocation statement I could not see why you used 20000L.
- after all 20000 is 20000, isn't it? */
-
- yycrank = farmalloc(20000 * sizeof(yynew));
- for (i = 0; i < 20000; i++)
- { j.current = 0;
- j.advance = i;
- *(yycrank+i) = j ;
- };
- }
-
-
- This compiled for me as well, and as Ian Gray pointed out, it is critical to
- make it 20000L and not just 20000. Try it in the debugger and see the
- difference.
-
- He also mentioned that:
-
- > in the above loop I tried several variants of assignment to the
- > fields of yycrank's records without success. Maybe someone else can
- > describe how to do such things as *(yycrank+i).current = 0
-
- I also had problems like that. I never did figure that out, and I don't
- understand why it is a problem.
-
- However, I still haven't gotten my REAL problem across which is that
- I want to make this definition GLOBAL! As I mentioned in my original
- post, I can do all these things inside of a function, but I want to
- make this initialization global so that I can use the initialization
- to initialize some other structures. Everything falls apart for me
- when I try to make these same definitions outside of a function.
-
- Any pointers would be appreciated.
-
- Cheers,
- Seth
-
-