Hi, I am having problems with passing arrays to DLLs and would like to know what to do. Here is an oversimplified example script.
#import "mydll.dll"double SecondValFromDLL(double p[]);#import
double SecondVal(double p[]) {
return (p[1]);
}
int start(){double p[5]={1.0,2.0,3.0,4.0,5.0};Alert("p[1] = ", SecondVal(p));// This works, returns 2.0Alert("p[1] = ", SecondValFromDLL(p));// This works, returns 2.0Alert("Close[1] = ", SecondVal(Close));// This works, returns Close[1]Alert("Close[1] = ", SecondValFromDLL(Close));// This does not work!!! NULL pointer.
return(0);}
After debugging the dll, I found that I was getting a valid pointer on the first case and a NULL pointer on the second case. Note that the problem is only when the array is passed to the DLL and not when its passed to the MT4 function.
What am I missing here?
[EDIT]
If I use ArrayCopy to copy the Close Array things work. My guess is that the internal arrays do not work with DLLs.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi, I am having problems with passing arrays to DLLs and would like to know what to do. Here is an oversimplified example script.
After debugging the dll, I found that I was getting a valid pointer on the first case and a NULL pointer on the second case. Note that the problem is only when the array is passed to the DLL and not when its passed to the MT4 function.
What am I missing here?
[EDIT]
If I use ArrayCopy to copy the Close Array things work. My guess is that the internal arrays do not work with DLLs.