Download MetaTrader 5

About include (mqh) processing

To add comments, please log in or register
Share your program via Code Base. Gain access to millions of traders!
Francis 2016.03.11 15:17 

Hi there,

Please a little elucidation about mechanism of include loading.

Let this scenario: there are some include (mqh) which in turn call other includes, i.e. relative to elementary soubroutines.

So, any include-container is an auto-independent module because it can be compiled without errors.

But a particular elemental included may be called by more of one include-container. And in general the include connections are how a tree.

For example: draw-form-input.mqh is an includer-container that require debug.mqh and draw-native-object.mqh; moreover statistical-analisys.mqh and delete-object.mqh are yper-containers that require draw-form-input.mqh and debug.mqh, and others peculiar files mqh.

Yes: it isn't necessary to recall again debug.mqh from delete-object.mqh because it is yet called by draw-form-input.mqh, but for my personal clarity I prefer to call debug.mqh in any of my mql-files: so I don't must care about structural changes.

Finally, the includes-container are called by the main procedure (mq4).

My question: during the main-procedure initialization, these elementary and repeated includes-soubroutine are loaded once or every time?





Carl Schreiber
Carl Schreiber 2016.03.11 17:24  
I have no inside view but I guess what is coded in a mqh-file that was loaded by a compile option is compiled as if it were coded directly within your EA.
whroeder1 2016.03.11 17:44  
  1. Includes are not repeatedly included.
  2. Includes are compiled as if it were coded directly within your EA at the first #include.
  3. Loaded once as part of the EA because the EA is loaded once.
Francis 2016.03.11 18:28  

Ok, thank's and have a nice day.

Ex Ovo Omnia
Ex Ovo Omnia 2016.03.11 18:37  
The compiler loads only the first include, like the include_once command in PHP. It's changed since the 509- code.
To add comments, please log in or register