How to use #import in MQL5?

 
Hi, everyone!

I started to use MT5 and MQL5.
I had a trouble in using #import.

The code of Libraries\import_test.mq5 is as below.

#property library
#property copyright "---"
#property link      "https://www.mql5.com"
#property version   "1.00"

void import_test(void) export
{
   Print("SUCCEEDED");
}

And the code of Indicators\TEST.mq5 is as below.

property copyright "---"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window

#property indicator_buffers 1
#property  indicator_plots 1

#import "import_test.ex5"
   void import_test(void);
#import

int OnInit()
  {
    import_test();
    return(INIT_SUCCEEDED);
  }
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
   return(rates_total);
  }

I compiled each code.

There is no problem in compiling import_test.mq5.

After I got import_test.ex5, I tired to compile TEST.mq5.

Then I had a error.

The error massage is : ')' - undeclared identifier.

And the message is given to 15th line of TEST.mq5, namely 'import_test();' which is inside OnInit function.


Why the compiling is failed?

I never had such problem while using MT4 and MQL4.

I read MQL5 Reference, but I can't find out big difference between MQL5 and MQL4 with using #import.

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
Predefined Macro Substitutions - Named Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

I realized that the file-name and the function-name must be different.

For example, if I choose the file-name as import_test.mql4, then I can't use   import_test for function-name.

I need to change the function-name to  import_test123() or something.

Is this the bug of MQL5 ?

I spend too much time for this trouble.

 
Thank you for your sharing. I wanted to know how to do function import.