Download MetaTrader 5

mqh multiple file inclusions?

To add comments, please log in or register
MQL5.community allows users to store their source codes in MQL5 Storage. Try it!
Nikolay
170
Nikolay 2016.02.24 12:30 

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
3148
Ex Ovo Omnia 2016.02.24 16:09  
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
170
Nikolay 2016.02.24 17:58  
Thank you Ovo!
whroeder1
14489
whroeder1 2016.02.27 12:43  
//+------------------------------------------------------------------+
//|  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