MICHELBI@oregon.uoregon.edu (Michel Biedermann) (04/10/90)
I am having problems declaring the following array as a global variable
using QuickC 2.0:
#define MAX_CHANNELS 6
#define MAX_SAMPLES 3000
float data[MAX_CHANNELS][MAX_SAMPLES];
void main(void)
{
/* use data[][] here */
}
In the interest of making this a good learning experience, please give me
both solutions (since my array is > 64K):
1. Using a small or medium memory model.
2. Using a huge memory model.
Thank you very much for any help.
Michel Biedermann michelbi.@oregon.uoregon.edu
U. of Oregon
MICHELBI@oregon.uoregon.edu (Michel Biedermann) (04/10/90)
I am having problems declaring the following array as a global variable
using QuickC 2.0:
#define MAX_CHANNELS 6
#define MAX_SAMPLES 3000
float data[MAX_CHANNELS][MAX_SAMPLES];
void main(void)
{
/* use data[][] here */
}
In the interest of making this a good learning experience, please give me
both solutions (since my array is > 64K):
1. Using a small or medium memory model.
2. Using a huge memory model.
Thank you very much for any help.
Michel Biedermann michelbi@oregon.uoregon.edu
U. of Oregon
walterb@hall.cray.com (Walter Boese) (04/10/90)
In article <18816@oregon.uoregon.edu>, MICHELBI@oregon.uoregon.edu (Michel Biedermann) writes: > I am having problems declaring the following array as a global variable > using QuickC 2.0: > > #define MAX_CHANNELS 6 > #define MAX_SAMPLES 3000 > > float data[MAX_CHANNELS][MAX_SAMPLES]; > > void main(void) > { > /* use data[][] here */ > } > > In the interest of making this a good learning experience, please give me > both solutions (since my array is > 64K): > 1. Using a small or medium memory model. > 2. Using a huge memory model. > The QC compiler does not handle the huge keyword, this is a CL option only. I don't belive that there is a huge model in QC. I have the full package - QC and CL compilers. The CL is an optimizing compiler that can handle the huge key word as well as huge models. In the CL compiler you would do the following: In a small or medium model, declare your data 'float huge data[][]'. This will work if your data is less than 128k, after that you have to size your array in powers of 2 or use a huge model. As for huge model, I believe you don't have to do anything. I think it should work. I'm not an expert programmer, but that is how I resolved the problem. Walter
pnl@hpfinote.HP.COM (Peter Lim) (04/12/90)
> I am having problems declaring the following array as a global variable > using QuickC 2.0: > > #define MAX_CHANNELS 6 > #define MAX_SAMPLES 3000 > > float data[MAX_CHANNELS][MAX_SAMPLES]; > > void main(void) > { > /* use data[][] here */ > } > > In the interest of making this a good learning experience, please give me > both solutions (since my array is > 64K): > 1. Using a small or medium memory model. > 2. Using a huge memory model. > > Thank you very much for any help. > > Michel Biedermann michelbi@oregon.uoregon.edu > U. of Oregon > ---------- You sure have a problem here. As far as I can remember, nothing in MS-DOS (short of using DOS extender) allow you to declare a 'simple' array > 64K size (PERIOD). You need to play with pointers. In your case, why don't just declare an array of 6 pointers, each is then used to index 3000 samples. Like: float (*dptr)[MAX_CHANNELS]; for (i=0; i < MAX_CHANNELS; i++) (*dptr)[i] = (float *) malloc ((unsigned) (MAX_SAMPLES * sizeof (float))); then proceed to use (*(dptr+j))[i] ..... in place of data[i][j]. /* NOTE: The above program fragments are dreamt up in the nick of time and I'm sure they will not work the first time. I can never quite remember the order of parenthesis; you need to play with them yourself. But I think the general idea is there. */ Regards, ## Life is fast enough as it is ........ Peter Lim. ## .... DON'T PUSH IT !! >>>-------, ########################################### : E-mail: plim@hpsgwg.HP.COM Snail-mail: Hewlett Packard Singapore, : Tel: (065)-279-2289 (ICDS, ICS) | Telnet: 520-2289 1150 Depot Road, __\@/__ ... also at: pnl@hpfipnl.HP.COM Singapore 0410. SPLAT !