Topic : fatal error C041 in using 2D array

Forum : Ride IDE

Original Post
Post Information Post
February 9, 2009 - 6:08am
Guest

//whats wrong with the following code?
//RIDE7 IDE 7.16.0000
//RKIT 2.14.0901
//LINKER/LOCATOR RLST7 V2.00.04 Lite (16 Kb code limited)

code unsigned char floors[32][8] = {
0x00, 0x06, 0x09, 0x08, 0x08, 0x0B, 0x09, 0x07, 0x00, 0x06, 0x09, 0x09, 0x09, 0x09, 0x09, 0x06,
0x00, 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x07, 0x00, 0x06, 0x09, 0x01, 0x02, 0x04, 0x08, 0x0F,
0x00, 0x06, 0x09, 0x01, 0x06, 0x01, 0x09, 0x06, 0x00, 0x09, 0x09, 0x09, 0x0F, 0x01, 0x01, 0x01,
0x00, 0x0F, 0x09, 0x08, 0x0F, 0x01, 0x09, 0x06, 0x00, 0x06, 0x09, 0x08, 0x0E, 0x09, 0x09, 0x06,
0x00, 0x0F, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x06, 0x09, 0x09, 0x06, 0x09, 0x09, 0x06,
0x00, 0x07, 0x09, 0x09, 0x07, 0x01, 0x01, 0x01, 0x00, 0x04, 0x0E, 0x15, 0x04, 0x04, 0x04, 0x04,
0x00, 0x04, 0x04, 0x04, 0x04, 0x15, 0x0E, 0x04, 0x00, 0x04, 0x04, 0x0E, 0x0E, 0x1F, 0x1B, 0x11,
0x00, 0x11, 0x1B, 0x1F, 0x0E, 0x0E, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

void main ( void )
{
unsigned char x,y,display;

while (1)
{
for(x=0;x<32;x++)
{
for(y=0;y<8;y++)
{
//display=floors[31][y]; //build suceeds when constant is used
display=floors[x][y]; //build fails when variable x is used (fatal error C041)
}
}
}
}

//although I am able to traverse the array in a 256 byte array (8*32) and solve my problem,
// I am just curious to know why the above wont work.

//thanks,
//Amey

Replies
Post Information Post
+1
0
-1
February 11, 2009 - 11:10am
Raisonance Support Team

Hi Amey,

We been able to reproduce your problem in our Labs.

The first thing to do is to use the LARGEOBJECT directive, as your array is 256 bytes wide. This fixes the problem.

However, we will correct the compiler so that the error message displayed in this case is more meaningful. The correction will be available in the next RKit-STM8 release. There is no release date planned, but there should be a release in Q2 anyway.

Thanks for your report,
Bruno