mqh multiple file inclusions?

Back to topics list To post a new topic, please log in or register
avatar
62
nikolaygmt 2016.02.24 13: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?

avatar
1109
Ovo 2016.02.24 17: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.
avatar
62
nikolaygmt 2016.02.24 18:58 #
 
Thank you Ovo!
avatar
12985
WHRoeder 2016.02.27 13: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

Back to topics list  

To add comments, please log in or register