#25880 - pyros - Mon Aug 30, 2004 7:23 pm
Today, I tried to make a big (32k) array like so:
However, when I wrote to the array things went bad. I don't think gcc was actually giving it enough memory.
When I defined the contents (i.e.)
it didn't cause the problem.
To work around this apparent compiler error I did this:
and then accessed the array as before (e.g.)
I am guessing that the problem was caused by gcc trying to put the array in IWRAM which is only 32k, thus overwriting everything in IWRAM including the program itself.
Does anyone know anything else about this? And am I doing anything bad?
I also thought a 'tips' forum might be nice as the coding forums are all labelled 'questions'. It would be an easy way to share short simple things, although i suspect there would be plenty of criticism for 'poor coding practice' and the like.
Paul.
Code: |
u8 myarray[32768]; |
However, when I wrote to the array things went bad. I don't think gcc was actually giving it enough memory.
When I defined the contents (i.e.)
Code: |
u8 myarray[32768] = {0,0,0,0.............}; |
it didn't cause the problem.
To work around this apparent compiler error I did this:
Code: |
u8* myarray;
myarray = (u8*) malloc(32768); |
and then accessed the array as before (e.g.)
Code: |
myarray[n] = x; |
I am guessing that the problem was caused by gcc trying to put the array in IWRAM which is only 32k, thus overwriting everything in IWRAM including the program itself.
Does anyone know anything else about this? And am I doing anything bad?
I also thought a 'tips' forum might be nice as the coding forums are all labelled 'questions'. It would be an easy way to share short simple things, although i suspect there would be plenty of criticism for 'poor coding practice' and the like.
Paul.