This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to assign the ram continuous without gap?

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
...
?

Parents
  • Another way to do it if you can deal with not having the strict record or struct approach, is to reorient the data into parallel arrays:

    #define N_SMPS 50
    
    unsigned char smp_attri[N_SMPS];
    unsigned char smp_data[N_SMPS];
    smp_attri[i]
    smp_data[i]

    You are unlikely to waste any memory that way.

Reply
  • Another way to do it if you can deal with not having the strict record or struct approach, is to reorient the data into parallel arrays:

    #define N_SMPS 50
    
    unsigned char smp_attri[N_SMPS];
    unsigned char smp_data[N_SMPS];
    smp_attri[i]
    smp_data[i]

    You are unlikely to waste any memory that way.

Children
No data