I have these lines in my code and was thinking that there may be some nice way to use preprocessor to generate these lines (0 through 31).
Mem_type MEM_0[MAX_NUM_MEM];
Mem_type MEM_1[MAX_NUM_MEM];
Mem_type MEM_2[MAX_NUM_MEM];
Mem_type MEM_3[MAX_NUM_MEM];
Mem_type MEM_4[MAX_NUM_MEM];
Mem_type MEM_5[MAX_NUM_MEM];
...
Mem_type MEM_30[MAX_NUM_MEM];
Mem_type MEM_31[MAX_NUM_MEM];
Mem_type *MEM[NUM_BANKS];
MEM[0] = MEM_0;
MEM[1] = MEM_1;
MEM[2] = MEM_2;
MEM[3] = MEM_3;
MEM[4] = MEM_4;
MEM[5] = MEM_5;
...
MEM[30] = MEM_30;
MEM[31] = MEM_31;
For example, something like:
#define Gen(n) MEM[n] = MEM_n
#for (k=0; k<32; k++) Gen(k);
(The reason why I don't do like the below is that I found that my machine has some maximum contiguous array size limit, so I tried to split it into separate arrays so that I can have larger aggregated MEM size.)
Mem_type MEM[NUM_BANKS][MAX_NUM_MEM];