somewhere in the beginning of the .cpp file 4 4-dimensional arrays are declared

#define NUM_OBJ 8 float array1[NUM_OBj][NUM_OBJ]; float array2[NUM_OBj][NUM_OBJ]; float array3[NUM_OBj][NUM_OBJ]; float array4[NUM_OBj][NUM_OBJ]; 

At a certain point, it was discovered that the 3 array intersects with addresses with 1 line of the second (i.e. during debugging, I saw that when filling in array 3, the first line of array 2 is also filled).

Previously, I always avoided working with global variables, but got someone else's code on pure C. Tell me, what could cause such a situation? MinGW 5.3.0

  • one
    #pragma pack is there? - Vladimir Martyanov
  • Declared like this, all 4 individually, and in one scope? How is it filled? by the usual assignment of array3[0][0] , roughly speaking, or by passing to a function? - Harry
  • Most likely your arrays are treading somewhere, or provide clear evidence of the intersection - Cerbo
  • @ Vladimir Martiyanov really helped. why is that? I usually just align the structure, but here it is and? - bronstein87
  • @Harry, by ordinary assignment, nothing is passed through the function arguments. As Vladimir pointed out above, the point is alignment. I do not understand the truth, why) - bronstein87

0