Bug in the MT4 using libraries or my fault ?

 

I use MT4 Version: 4.00 Build 225. Something doesn't work using library. I can state easy example :

\experts\libraries\

------------------------------- test.mq4 -----------------------

#property library

void foo1(int& ret)
{
ret=123;
}

void foo2(int& ret[])
{
ret[0]=123;
}
------------------------------------------------------------------

\experts\include\

------------------------------- test.mqh -----------------------

#import "test.ex4"

void foo1(int& ret);
void foo2(int& ret[]);

------------------------------------------------------------------

\experts\scripts\

------------------------------- testing.mq4 --------------------

#include <test.mqh>

int start()
{
int numb;
int arr[1];
foo1(numb);
foo2(arr);
Alert(numb," ",arr[0]," Why is the constant bad (result=0) and the array OK (result=123) ?");
}

------------------------------------------------------------------

It takes me considerable time to discover the bug. I prefer using arrays. May be it helps somebody....

If it is my fault, sorry for misinform. Who can explain it ?

Thanks

Ron

 

Please check this document,

https://docs.mql4.com/basis/variables/extfunctions

  • If there is a need to pass data of the int or double type, then the one-dimensional array of the corresponding type should be passed by reference as a parameter.
 

yes, MT now only support array as parameter for data transfer back. or use return to return single varible.

any other simple type varible only can be used to trans parameters into function, not for out.

and CANNOT change or dynamic relocate memory for parameter.