MQL5 : Header (mqh) file unable to use parent mql file's struct variable

 

Hi,

I have a EA which has a struct defined in it (because there are variables of its type in the EA mql file) and the struct type is being used to declare a variable in the header file too.

// within mql EA file
 struct LLevel
  {
    .....
 }


// within mqh file
LLevel expiredLLevel[];

After i include the mqh file in EA and compile i get error:

'LLevel' - unexpected token, probably type is missing?


Is it not possible to use parent mql file's variables and struct defined , within included mqh file? 
Is there a workaround? 
How do programmers generally deal with this problem? 
 
Nevermind. I was including the mqh file before the struct was declared in the parent mql file. This issue has been resolved.
 

Hi

If I understand you correctly, you need to simply declare the struct before declaring the variable.

Can you simply declare the struct in the header file? Or declare the variable in the mql file (below the struct definition). This would be the simplest solution.

Best Regards

 
Marzena Maria Szmit #:

Hi

If I understand you correctly, you need to simply declare the struct before declaring the variable.

Can you simply declare the struct in the header file? Or declare the variable in the mql file (below the struct definition). This would be the simplest solution.

Best Regards

Yeah you are correct. I was using the struct (present in mqh) before it was declared (in parent file). I solved it by just moving the #include <...mqh> after my declaration of struct. 

Reason: