Communication with DLL doesn't work as it should. Here are two code samples:
DLL:
EA:
Result:
2014.02.08 11:40:31.121 2011.09.06 00:00 ANNEA27 EURAUD,M5: DOUBLE TEST: 0.5 0.5 1 0.5
OTHER VARIANT:
RESULT:
2014.02.08 11:57:57.976 2011.09.06 00:00 ANNEA27 EURAUD,M5: DOUBLE TEST: 0 0 0 0.5
Communication with DLL doesn't work as it should. Here are two code samples:
DLL:
EA:
Result:
2014.02.08 11:40:31.121 2011.09.06 00:00 ANNEA27 EURAUD,M5: DOUBLE TEST: 0.5 0.5 1 0.5
OTHER VARIANT:
RESULT:
2014.02.08 11:57:57.976 2011.09.06 00:00 ANNEA27 EURAUD,M5: DOUBLE TEST: 0 0 0 0.5
I experienced same problem, too. I thought it was something C++ related, as I was not C++ educated. A dynamic array cannot be used as a param for dll function call. This information cost me several hours of my life.
A dynamic array cannot be used as a param for dll function call. This information cost me several hours of my life.
Eeek, the above code works fine in v509.
Have you seen any piece of documentation for v600 which says that dynamic arrays are not supposed to work, or is this a bug?
What is coded within TestDouble() ?
The code for TestDouble() is at the top of the page.
When compiled & run with v509, both versions of the code give the same output: DOUBLE TEST: 0.5 0.5 1 0.5
When compiled & run with v604, the two versions are different as posted above. Passing a dynamic array to the DLL is not working. I suppose that this could be a deliberate loss of functionality compared to v509 - though a very unintuitive and dangerous one - but it looks much more like a bug.
Why?
... Aaaah, it's not a bug in MT4. It's a missing compiler warning.
You're not meant to use ArrayResize on a statically declared array. If you change the code to double out[]; then the problem disappears.
(When compiling on MT5, the compiler does warn about this use of ArrayResize.)
Yeah, I use MT4, there is no such warning, and code worked before ;/ If it is deliberate (and if MT5 works as gchrmt4 had said, it is), then they should have documented it. I have lost quite a lot time tracking this.
By the way, it looks, like when you resize an array, old array is passed to DLL, but new array is used in MQL. You can write all you want on old array, it won't change anything, but at the same time, you won't get null pointer exception.
The code for TestDouble() is at the top of the page.
When compiled & run with v509, both versions of the code give the same output: DOUBLE TEST: 0.5 0.5 1 0.5
When compiled & run with v604, the two versions are different as posted above. Passing a dynamic array to the DLL is not working. I suppose that this could be a deliberate loss of functionality compared to v509 - though a very unintuitive and dangerous one - but it looks much more like a bug.
Oops,..I was a little blind.
...and we should all have reached the correct answer sooner <g>
Declaring a static array and then trying to resize it is a fairly uncommon thing for a programming language to allow, and old MQL4 is relatively unusual in permitting it. Given the type of changes in the new MQL4, one of us really should have got to this answer quicker.
...and we should all have reached the correct answer sooner <g>
Declaring a static array and then trying to resize it is a fairly uncommon thing for a programming language to allow, and old MQL4 is relatively unusual in permitting it. Given the type of changes in the new MQL4, one of us really should have got to this answer quicker.
mql5 produce a warning :
Cannot be used for static allocated array Test.mq5 22 4
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Communication with DLL doesn't work as it should. Here are two code samples:
DLL:
EA:
Result:
2014.02.08 11:40:31.121 2011.09.06 00:00 ANNEA27 EURAUD,M5: DOUBLE TEST: 0.5 0.5 1 0.5
OTHER VARIANT:
RESULT:
2014.02.08 11:57:57.976 2011.09.06 00:00 ANNEA27 EURAUD,M5: DOUBLE TEST: 0 0 0 0.5
Why?