Download MetaTrader 5

mqh multiple file inclusions?

To add comments, please log in or register
Nikolay
175
Nikolay  

If myIndicator.mq4 includes:

#include "commonInclude.mqh"

#include "include1.mqh" 

#include "include2.mqh" 

and

both include1.mqh and include2.mqh include:

#include "commonInclude.mqh"

// custom code

how many times will commonInclude.mqh be included in the compiled version?

Ex Ovo Omnia
3190
Ex Ovo Omnia  
nikolaygmt:

If myIndicator.mq4 includes:

#include "commonInclude.mqh"

#include "include1.mqh" 

#include "include2.mqh" 

and

both include1.mqh and include2.mqh include:

#include "commonInclude.mqh"

// custom code

how many times will commonInclude.mqh be included in the compiled version?

You may include it as many times as you need it, but only the first appearance is used by the compiler.
Nikolay
175
Nikolay  
Thank you Ovo!
whroeder1
14785
whroeder1  
//+------------------------------------------------------------------+
//|  9:47 AM 8/8/2015                               basic_types.mqh |
//|                              Copyright © 2015, William H. Roeder |
//+------------------------------------------------------------------+
#ifndef BASIC_TYPES_MQH
#define BASIC_TYPES_MQH
//+------------------------------------------------------------------+
   :
#endif   // BASIC_TYPES_MQH
//+------------------------------------------------------------------+
Or put include guards like C++ and don't assume
To add comments, please log in or register