Declaration of 'varaible 1' hides global variable (warning) Please help, cannot find the solution sine hours!
I triple checked, there is no other declaration for these variables in another section of the code.
😄
mq4 file:
#include <TEST.mqh>
input double variable2 = 20;
No warning when I only compile the mq4 file(where I also use these variables) but when I include the TEST.mqh i get this Declaration of 'varaible 1' "variable2" hides global variable warning.
TEST.mqh code example
// -- Trade Logic --
ENUM_ORDER_TYPE GetTrade(int variable1, double variable2)
input int variable1 = 10; input double variable2 = 20; ⋮ ENUM_ORDER_TYPE GetTrade(int variable1, double variable2)
- In your function, you have a local variable (first parameter) and a globally declared variable with the same name.
- If you intend to only use the global ones, remove the parameters from your function definition.
MQH indicates an include (header) file. You do not compile them, you include them.
I always compile mqh files so that the compiler can check them. I believe that every header file should compile without errors and warnings regardless of the mq4/5 file.
That is, when I write another mqh file, I compile this mqh file to immediately check the just written code for errors without having to return to the mq4 file, which often I don’t even have open.
This is what the mq4 file of the expert I'm working on at the moment looks like:
I don't need this file 99.9% of development time (thanks to the fact that I compile mqh files for the compiler to check for errors😄)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
mq4 file:
#include <TEST.mqh>
input double variable2 = 20;
No warning when I only compile the mq4 file(where I also use these variables) but when I include the TEST.mqh i get this Declaration of 'varaible 1' "variable2" hides global variable warning.
TEST.mqh code example
// -- Trade Logic --
ENUM_ORDER_TYPE GetTrade(int variable1, double variable2)
I triple checked, there is no other declaration for these variables in another section of the code.
Thank you very much for your support!