Use a third include file.
Thanks for the response.
If I do what I think you're suggesting, I would just end up removing the enum definition from the first two includes, put it in a third include, but when I'm working on one of the first two includes and try to compile (to check for errors), it'll give me an error stating "declaration without a type."
Thanks for the response.
If I do what I think you're suggesting, I would just end up removing the enum definition from the first two includes, put it in a third include, but when I'm working on one of the first two includes and try to compile (to check for errors), it'll give me an error stating "declaration without a type."
Like Alain said, use a third file:
// theenum.mqh enum TheEnum {}; // include_a.mqh #include <theenum.mqh> // include_b.mqh #include <theenum.mqh> // main.mqh #include <include_a.mqh> #include <include_b.mqh>This way the enum will be always included if you use your include a or b.
Like Alain said, use a third file:
This way the enum will be always included if you use your include a or b.Ahh, I get it now.
Thanks for the help!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Let's say I have a main file (main.mq4) and 2 include files
main.mq4 file looks like this:
both include files have the same enum defined, say
enum FirstName { John, Mary };
When I try to compile the main file, it throws an error saying that the enumerator and its identifiers are already defined.
Now, I know I could remove the definition of the enum from one of the include files and it'll compile perfectly, but if I try to compile the include file that is missing the enum, it throws an error saying, " FirstName - declaration without type", which is expected, but I don't want to have to see that message every time I try to compile.
Is there a way around this?
Edit: I know that include files aren't necessarily compiled, but that's what I use to check for errors in MetaEditor while working on the include file.