I define a struct array struct smp { unsigned char attri; unsigned char data; } smp[50]; but I find the compiler make a gap between the array. In fact the ram is assigned as smp[0].attri smp[0].data gap[0] gap[1] smp[1].attri smp[1].data gap[0] gap[1] ... so the ram of gap can not be used, then half of the ram is wasted. how can I make the ram of gap to be useful? Can the ram be assign continuous as define a struct array? Can the ram be complied as smp[0].attri smp[0].data smp[1].attri smp[1].data smp[2].attri smp[2].data ... ?
Godday, It seems that you have found a small bug in the CA compiler. The struct size is rounded up to the next multiple of 4, this should not be the case here. Until this is fixed, the following workaround avoids wasting memory space:
#pragma save pack(1) struct smp { unsigned char attri; unsigned char data; } smp[50]; #pragma restore #if 0 // Alternatively, the following is also Ok.: __packed struct smp { unsigned char attri; unsigned char data; } smp[50]; #endif void main (void) { //... }
Well, so thanks for the replys. My problem always can be solved. The discusser here are so kind and nice.