Download MetaTrader 5

How does the compiler and the editor determines include-files to be meant for either mt4 or mt5?

To add comments, please log in or register
Carl Schreiber
Carl Schreiber  

Well this is my situation: I speak about two include files: Errors.mqh and CmyClass.mqh both in ..\MQL4\Include\ which I want to compile individually to detect 'grammatical' errors!

I created a class CmyClass.mqh which contains the class method: bool CmyClass::sndOrd(..) the mt4 call OrderSend(..) - with its specific parameters that are different to the function with the same name for mt5!

It compiles without an error!

Now I copied the class method bool CmyClass::sndOrd(..) with the mt4-method with OrderSend(..) to another file: MQL4\Include\Errors.mqh.

This Errors.mqh compiles without any error previously but after 1) copying the whole method into is and re-naming it to bool __template__sndOrd(..):

  1. it compiles with error (among many others: 'OrderSend' - wrong parameters count    Errors.mqh    998    14
  2. if I press F1 with the cursor above OrderSend(..) the reference of mt5 opens?
  3. if I press F1 in CmyClass.mqh the reference of MQL4 opens?

Now I start playing around!

  1. I 'wrapped' the method by #ifdef __MQL4__ ... #endif and Errors.mqh compiles without any error - :)
  2. But now I (accidently) did not renamed the class method (having now bool CmyClass::sndOrd(..) wrapped by
    #ifdef __MQL4__ ... #endif) - and that compiles with no Error - even though the Class CmyClass must be unknown (I just compile Errors.mqh)!
  3. If I wrap it by #ifdef __MQL5__ ... #endif I get not only the prev. compiler errors but also a hint that CmyClass is unknown.

So this leads to my following questions:

  1. Why does the compiler recognizes at least CmyClass.mqh with OrderSend() as a mq4-file as I don't have any #ifdef __MQL4__ ... #endif there?
  2. What are the keys that the editor 'knows' what reference (mql4 or mql5) has to be opened if F1 is pressed?
  3. Why does the MQL4-wrapping ignores the missing class?

Thanks and a nice Sunday.


PS: To create a dynamic behaviour I wrote in Errors.mqh which compiles without any error!!:


Unfortunately I think if I tell this to the Service Desk I'll get the answer: We have no intentions to change this.

To add comments, please log in or register