This warning is really annoying, I don't know why the developer team won't fix it. This warning is nonsense when a global variables name is the same as a local variables name in another file. The compiler should generate the warning only when both declarations are in the same file.
When we use a lot of libraries it gets even worse.
don't blame MQL guys...blame B. Stroustrup but i don't think he will listen anyway
This warning is really annoying, I don't know why the developer team won't fix it. This warning is nonsense when a global variables name is the same as a local variables name in another file. The compiler should generate the warning only when both declarations are in the same file.
When we use a lot of libraries it gets even worse.
You don't understand the the mqh-files. They are inserted and then the compilers takes both as one file
I think if you declare it once in a local scope you should not be getting that. Sometimes declaring it twice causes the problem rather change the naming.
Suppose you write a library for me with thousands of files, functions and classes. You write a function with a local variable "temp". I include your library to my main code and declare a global variable with the name "temp" and the compiler says hey warning, your friends variable hides your variable. Then I try to change the name to temp1 and it says the same warning again and again.
The problem with the compiler is that it dose not understand the file scope. It mixes everything then compiles.
Suppose you write a library for me with thousands of files, functions and classes. You write a function with a local variable "temp". I include your library to my main code and declare a global variable with the name "temp" and the compiler says hey warning, your friends variable hides your variable. Then I try to change the name to temp1 and it says the same warning again and again.
The problem with the compiler is that it dose not understand the file scope. It mixes everything then compiles.
Suppose you write a library for me with thousands of files, functions and classes. You write a function with a local variable "temp". I include your library to my main code and declare a global variable with the name "temp" and the compiler says hey warning, your friends variable hides your variable. Then I try to change the name to temp1 and it says the same warning again and again.
The problem with the compiler is that it dose not understand the file scope. It mixes everything then compiles.
Just try to avoid to use global variables or mark them in a special way.
This warning warns you about a situation that may cause really nasty and hard to find bugs.
Changing naming must work, you are just doing something wrong.
I understand. Its really annoying then cause whats the alternative way if even changing naming does not work?
you could wrap the library inside a namespace though
In python yes, but not in C langs and not in MQL. This is a must read for you... https://www.learncpp.com/cpp-tutorial/why-global-variables-are-evil/
I'm programming for 20 years by now and I know how to use global variables the right way.
No, It's absolutely not the case for C languages. Accessing a not defined/declared variable in C languages is an error, but in MQL it's not.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This warning is really annoying, I don't know why the developer team won't fix it. This warning is nonsense when a global variables name is the same as a local variables name in another file. The compiler should generate the warning only when both declarations are in the same file.
When we use a lot of libraries it gets even worse.