Open GWRon opened 10 months ago
The generated code indicates that the C code uses "1 dimensional arrays" and simply adds up the passed indices of the multi-dimensional access to a single index.
Local int_array:Int[1,1,2]
int_array[0,0] = 4
int_array[1,0,0] = 4
becomes
BBARRAY bbt_int_array=bbArrayNew("i", 3, 1, 1, 2);
BBUINT* bbt_=((BBARRAY)bbt_int_array)->scales + 1;
((BBINT*)BBARRAYDATA(bbt_int_array,1))[(*(bbt_)) * 0U + 0U]=4;
BBUINT* bbt_2=((BBARRAY)bbt_int_array)->scales + 1;
((BBINT*)BBARRAYDATA(bbt_int_array,1))[(*(bbt_2)) * 1U + (*(bbt_2+1)) * 0U + 0U]=4;
Does not help much though -- regarding the BCC checks, but explains why it is "working" (as long as you just leave out dimensions / aka setting their index indirectly to "0")
@MidimasterSoft wrote at discord:
' now call the array with one dimension too small, but no error message: Test[0,0]=4
Print Test[0,0,0] + " " + Test[0,0,1]
Building untitled1 Compiling:test.bmx Compile Error: Incorrect number of array dimensions [C:/code/test.bmx;4;1] Build Error: failed to compile C:/code/test.bmx Process complete