home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 11907 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.3 KB  |  84 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!mcsun!sunic!dkuug!daimi!aau!psykseth
  3. From: psykseth@aau.dk (Seth Chaiklin)
  4. Subject: structures >64K
  5. Message-ID: <1993Jan8.135612.14930@aau.dk>
  6. Summary: How do you make a structure over 64K?
  7. Keywords: struct, huge
  8. Organization: Aarhus University, Denmark
  9. Date: Fri, 8 Jan 1993 13:56:12 GMT
  10. Lines: 72
  11.  
  12. I am having problems making a 'huge' struct.  As some of you may
  13. remember from last month, I was asking about how to make arrays
  14. over 64K.  Well now I am trying (rather unsuccessfully) to
  15. achieve the following:
  16.  
  17. (a) initialize a structure that is about 80K
  18. (b) have that structure be global.
  19.  
  20. The structure itself is not very complicated:
  21.  
  22. struct yynew {
  23. int current;
  24. int advance;
  25. };
  26.  
  27. and the initialization is just small integers
  28.  
  29. yycrank[] = {1,2,3,4,0,175,0,1,175...};
  30.  
  31.  
  32. And it all works just fine as stated, provided the initialization is under
  33. 64K.  But I want to use about 40,000 integers in initializing this
  34. structure, and that is where my problem begins.  
  35.  
  36. I cannot figure out how to declare yycrank to be a 'huge' structure in
  37. Turbo C 2.0.
  38.  
  39. I can't seem to be able to declare yynew to be huge.
  40.  
  41. For example:
  42.  
  43. typedef struct huge yynew {
  44. int current;
  45. int advance;
  46. } YYNEW;
  47.  
  48. gives a "structure or union syntax error "
  49.  
  50. And if I try something like:
  51.  
  52. YYNEW huge yycrank;       /* conflicting type modifiers  - fair enough */
  53.  
  54. huge YYNEW yycrank;      /* syntax error */
  55.  
  56. Ok -- so I get the idea (by implication) from the Turbo C manual that 
  57. I have to use a pointer to get a big structure.  So I try something like this:
  58.  
  59. YYNEW  *yycrank;
  60. yycrank = (YYNEW huge *) farmalloc(20000L * sizeof(YYNEW));
  61.  
  62. Well that will compile if it is placed inside of a function (though the 
  63. compiler (rightfully) complains about a suspicious pointer conversion.
  64.  
  65. But if I try to compile this globally then I get these errors
  66.  
  67.    Declaration needs type or storage class
  68.    Type mismatch in redeclaration of 'yycrank'
  69.    Illegal initialization
  70.  
  71. plus the warning:
  72.  
  73.    Suspicious pointer conversion
  74.  
  75.  
  76. Aaarrrggghhh!  Given that it is possible to do all this if I am working
  77. under 64K.  Then I would assume that there must be a way to allocate
  78. memory for a structure that is over 64K.  But my various trials and
  79. errors have been discouragingly unsuccessful.  Advice appreciated.
  80.  
  81. Cheers,
  82.   Seth
  83.   psykseth@aau.dk
  84.