Download MetaTrader 5
To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
Lexeon
14
Lexeon 2016.07.31 04:17 

I have a DLL that will return a pointer to an array of structs:

struct dataSet{

        //some random variables

}; 

dataSet* RandomFunction(const int ratesTotal, const double price[]) { 

        //some random calculations

}

However, I do not know how to import this function in mql5. I have tried doing

#import "RandomDLL.dll"
   dataSet[] RandomFunction(const int ratesTotal, const double& price[]);
#import

 However when I compile my code I get two errors:

'[' - name expected

'double' - name expected

 

I assume the 'double' error is just residue from the return type not being correct. Does anyone know how to properly import a function from a DLL that returns a pointer to an array? 

Lexeon
14
Lexeon 2016.08.01 05:29  
It seems that it doesn't matter if I'm trying to return an array or not. I get the error if I even try to return just a single struct, but it compiles if I change the return type to an int or a float.
Stanislav Korotky
17336
Stanislav Korotky 2016.08.02 11:15  
AFAIK, you can't import structs from DLLs. Use standard types instead. To return an array of doubles, for example, you should pass array of doubles by reference into DLL function and it will fill it with output.
/
To add comments, please log in or register