Eclipse debugger expression window using matrixes [message #1772164] |
Wed, 06 September 2017 04:51  |
Eclipse User |
|
|
|
Hi,
I am trying to run the below code in the Eclipse debugger and view the matrixes in the "Expression" window. I have set a breakpoint in "myFunction()" at the first for-loop and executed the program until this point. Then I added the "myGlobalMatrix" and "myInputMatrix" to the "Expression" window. In the "Expression" window I can see "myGlobalMatrix" with the [3][4] dimensions and the values inside properly. The "myInputMatrix" shows (*)[4] instead of [3][4] even if the size of the matrix is the same. When looking into the "myInputMatrix" it shows "0,10,20,0" which is the first value in each inner dimension. However, the last 0 is outside the matrix. In order to show "myInputMatrix" correctly in the "Expression" window, "Display As Array" needs to be used by rightclick on the type of "myInputMatrix" and choose the right length of the outer dimension (3).
Why is this extra step needed when looking at input matrixes to a function and not to global matrixes ?
If this is not done, the "myInputMatrix" in "Expression" window does not make any sense.
Ex:
Name : matrix.c
#include <stdio.h>
#include <stdlib.h>
int myGlobalMatrix[3][4] =
{{0, 1, 2, 3},
{10, 11, 12, 13},
{20, 21, 22, 23}};
int myFunction(int myInputMatrix[3][4]);
int myFunction(int myInputMatrix[3][4])
{
int sum,i,j;
for (i=0; i < 3; i++)
{
for (j=0; j < 4; j++)
{
sum += myInputMatrix[i][j];
}
}
return sum;
}
int main(void)
{
int mySum = 0;
mySum = myFunction(myGlobalMatrix);
return EXIT_SUCCESS;
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.04138 seconds