need help with large arrays & Turbo C
terry at joshua.math.ucla.edu
terry at joshua.math.ucla.edu
Fri Jun 14 11:35:24 AEST 1991
Help! I am having trouble porting a program from Microsoft C 5.x (I think)
to Turbo C 2.0.
The problem concerns some arrays. In the MSC source, they are defined in
one module as
unsigned huge buf[131072]
float huge difbuf[32][1024]
In the headers of the other source files, the variables are referred to as
extern unsigned huge buf[]
extern float huge difbuf[32][1024]
This has to be compiled with the medium memory model.
Turbo C has two complaints:
1. The arrays are too big (each is bigger than one segment)
2. "huge" can only modify pointers, not arrays
It seems that with Turbo C, I have to declare something like
unsigned huge *buf
buf = farmalloc(131072L * sizeof(unsigned))
and in the other files put
extern unsigned huge *buf
Now, according to the FAQ, *buf and buf[] are not quite the same; I'm
afraid I am making some mistake in the extern definition. However, I want
to keep the 'huge' modified in there to beware of pointer arithmetic.
I'm entirely unsure what to do with the 2D array, difbuf.
And lastly, I want to initialize these arrays with memset(), but memset()
only sets up to 65535 elements. The arrays may change in size; is there a
good way to figure the size at run time and initialize with several calls
to memset()?
Please help! Please send your replies by e-mail; I will post a summary.
Thanks!
terry
More information about the Comp.lang.c
mailing list