What happened to array sizing?!?

 

Guys, there are strange things in MT4 with array sizing that never happened before.

If I use this, no problem:

double array[65529];

But if I use this, I got a compiler message ("the size of local variables is too large (more than 512kb)")

double array[65530];

I can't remember such limitations in the past.

Also, earlier I could define a function like this:

#define SIZE1  10

#define SIZE2  20

int SomeFunction(int array[SIZE1][SIZE2]){...}

But now, it doesn't work, SIZE1 is ignored.

Can you confirm my observations?

 
linux80s:

Guys, there are strange things in MT4 with array sizing that never happened before.

If I use this, no problem:

But if I use this, I got a compiler message ("the size of local variables is too large (more than 512kb)")

I can't remember such limitations in the past.

Also, earlier I could define a function like this:


But now, it doesn't work, SIZE1 is ignored.

Can you confirm my observations?

The second question, it doesn't make sense to define a size for first dimension of array in function definition.
 
Mohammad Hossein Sadeghi:
The second question, it doesn't make sense to define a size for first dimension of array in function definition.
Why?! It is a static array. I always did it and worked well.
 
For first question, there has been such limitation as documented here: https://docs.mql4.com/constants/errorswarnings/warningscompile

Try an array of dynamic size and resize it as needed.
 
linux80s:
Why?! It is a static array. I always did it and worked well.
Because array is defined in the body, not in the function definition.
 
Mohammad Hossein Sadeghi:
Because array is defined in the body, not in the function definition. 

I think it is a false statement. Where do you see such rule?

As I said, this worked well until now. But now it stopped working.

Regarding the first problem: is there any array-size limitation?

 
linux80s:

I think it is a false statement. Where do you see such rule?

As I said, this worked well until now. But now it stopped working.

Arrays are passed to functions by reference.
I tried to help.
If it worked before, it doesn't mean it was correct.
 
linux80s:

...

Regarding the first problem: is there any array-size limitation?

Yes, the system resources, if the memory is full, or it can not be allocated, the ArrayResize function won't succeed.
 
There's always a limit on index size:

Total amount of elements in the array cannot exceed 2147483647.
 
Mohammad Hossein Sadeghi:
Arrays are passed to functions by reference.
I tried to help.
If it worked before, it doesn't mean it was correct.

Yes, I forgot to write the &:

int SomeFunction(int &array[SIZE1][SIZE2]){...}

Array sizing: this code below gives 0.

double array[][5000];
ArrayResize(array,5000);
Print(ArraySize(array));
 
linux80s:

Yes, I forgot to write the &:

Array sizing: this code below gives 0.

You should check the return value of ArrayResize, if it is false, then check for error using GetLastError.
Reason: