Re: NXC array declaration
Posted: 01 Oct 2012, 20:57
The problem also exists without dimensions specified. I will then post my example. Maybe it is another problem, but also affecting the initialization.
This is the code example:
myArray[1][2] ends up "0", instead of "1.0". In fact, from some more tests, I got:
What doesn't work(for myArray[1]):
{0.0, 0.5, 1.0}
{0.0, 0.5, 1}
{0.0, 0.5, 2.0}
{0.0, 0.5, 3}
What works - correctly initialized and displayed:
{0.0, 0.5, 1.1}
{0.0, 0.5, 1.5}
{1, 2, 3}
{0.0, 0.5, 3}
I did most of this tests using Optimization level 0, 1 and 2 and also tried with FW 1.2.9, 1.3.1 and the latest 1.3.2 (from August 2012).
I could be missing something...
This is the code example:
Code: Select all
float myArray[][] = { {0.0, 1.0, 0.0}, {0.0, 0.5, 1.0} };
task main(void){
ClearScreen();
NumOut(0, LCD_LINE1, myArray[0][0]);
NumOut(20, LCD_LINE1, myArray[0][1]);
NumOut(40, LCD_LINE1, myArray[0][2]);
NumOut(0, LCD_LINE2, myArray[1][0]);
NumOut(20, LCD_LINE2, myArray[1][1]);
NumOut(40, LCD_LINE2, myArray[1][2]);
while(true);
}
What doesn't work(for myArray[1]):
{0.0, 0.5, 1.0}
{0.0, 0.5, 1}
{0.0, 0.5, 2.0}
{0.0, 0.5, 3}
What works - correctly initialized and displayed:
{0.0, 0.5, 1.1}
{0.0, 0.5, 1.5}
{1, 2, 3}
{0.0, 0.5, 3}
I did most of this tests using Optimization level 0, 1 and 2 and also tried with FW 1.2.9, 1.3.1 and the latest 1.3.2 (from August 2012).
I could be missing something...