🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
1 messages
1 total messages Started by Seth Chaiklin Tue, 12 Jan 1993 11:58
GLOBAL structs > 64K
#7606
Author: Seth Chaiklin
Date: Tue, 12 Jan 1993 11:58
49 lines
1816 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads