bitchy preprocessor ..
At least this works:
//+------------------------------------------------------------------+ //| test_PreProc.mq5 | //| Calli | //| https://www.mql5.com/de/users/gooly | //+------------------------------------------------------------------+ #property copyright "Calli" #property link "https://www.mql5.com/de/users/gooly" #property version "1.00" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ #define _arWsz(A) __FUNCTION__+"["+(string)__LINE__+"] "+ #A+"[] sz: " + (string(ArraySize(A))) // print array with array name template<typename T> void ArrayPrt(T &arr[], const string inf) { Print(inf); ArrayPrint(arr); } void OnStart() { //--- int a[]={-5,-4,-3,-2,-1,0,1,2,3,4,5}; double b[]={1,5,2.4,3.3}; ArrayPrt(a,_arWsz(a)); ArrayPrt(b,_arWsz(b)); } //+------------------------------------------------------------------+
=>
2023.07.14 09:33:18.353 test_PreProc (EURUSD,H1) OnStart[27] a[] sz: 11
2023.07.14 09:33:18.353 test_PreProc (EURUSD,H1) -5 -4 -3 -2 -1 0 1 2 3 4 5
2023.07.14 09:33:18.353 test_PreProc (EURUSD,H1) OnStart[28] b[] sz: 4
2023.07.14 09:33:18.353 test_PreProc (EURUSD,H1) 1.00000 5.00000 2.40000 3.30000
This does not compile:
But this does and it works as intended:
Why?
Here the script to test:
This prints:
This does not compile:
'#arr' - invalid preprocessor command test_PreProc.mq5 19 15
But this does and it works as intended:
'test_PreProc.mq5' test_PreProc.mq5 1 1
code generated 1 1
0 errors, 0 warnings, 107 msec elapsed 1 1
Why?
Here the script to test:
This prints:
2023.07.14 09:22:19.189 test_PreProc (EURUSD,H1) -5 -4 -3 -2 -1 0 1 2 3 4 5
2023.07.14 09:22:19.189 test_PreProc (EURUSD,H1) 32 arr[] sz: 4
2023.07.14 09:22:19.189 test_PreProc (EURUSD,H1) 1.00000 5.00000 2.40000 3.30000