You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In general, we should start with the fact that global variables are evil, and when such a variable is used in many files and can be changed from anywhere, then it's evil squared! Therefore, such variables should always be declared as constant (unless we are talking about auxiliary variables for debugging purposes, which do not affect the logic of the algorithm).
The extern specifier is needed if the project consists of several mq5 files (not to be confused with mqh). In this case, it makes sense to declare global variables in a separate file. If the project consists of mqh and is built using #include, extern is not needed since it is one file divided into several files.
example is needed, I have tried using extern in libraries - it doesn't workhttps://www.mql5.com/ru/forum/316795/page2#comment_12259472
example is needed, I have tried using extern in libraries - it doesn't workhttps://www.mql5.com/ru/forum/316795/page2#comment_12259472
Here, in the second case, you need extern, which would enter the global variables in the scope of different files.
I don't mind, but I need an example, here you can guess where to use extern - I tried it in the library, it didn't work, show me how you use extern
It is not for libraries, but for projects. The project can be built either on #include or make several mq5 files. In the second case, extern is needed to enter global variables into scope of different files.
The whole point is that extern turned out to be simply unnecessary. A variable declared globally in any project file is available in all of its files. But why? Question for the creators.
You can declare an extern variable in all *.mqh files, in which it is used.
Then, such *.mqh files do not depend on *.mq5 (or other *.mqh) file, in which the global variable is declared.
This allows you to use the files in other projects, increasing code reuse.
You can declare extern variable in all *.mqh files, in which it is used.
Then, such *.mqh files do not depend on the *.mq5 (or other *.mqh) file, in which the global variable is declared.
This allows you to use the files in other projects, increasing code reuse.
Thanks, now I understand the logic. I originally thought it was similar to extern in C++.
Isn't it similar?