Do errors prevent compiliing

 

I know this is a weird question, but I'm trying to figures out what kind of things are possible in MT4, so I'm experimenting.

If an include file has errors saying that a variable is not defined, but it is defined in the mq4 file that #includes it, will the script or indicator still operate properly?

Specifically. I want a variable (#define myVariable "something") to ONLY be available to the include file it's #defined in. I can do that by putting the #include statement at the bottom of the mq4 file. But I also want variables to be available to both the mq4 file and the include file.

So I create 2 include files (file_top.mqh and file_bottom.mqh), and #include them both in myScript.mq4. file_top.mqh ONLY has the variables that I want available to both myScript.mq4 and file_bottom.mqh. file_bottom.mqh has all the functions() and the special variable (myVariable). I put the #include statements at the top and bottom of myScript.mq4. That way myVariable is not available to myScript.mq4. But when I compile file_bottom.mqh I get the errors that all the other variables are not defined (all the variables in file_top.mqh). But when I compile myScript.mq4 there are no errors.

Or is there some other way to have a #defined variable to only be available to the mqh file and not available to the mq4 file that #includes it?

 
FoxGuy:
Or is there some other way to have a #defined variable to only be available to the mqh file and not available to the mq4 file that #includes it?

No. Once you define something it's available from that point on.

You can create a library (one compiled unit) and then create a include file with the #import ex4. Only the function definitions can be seen plus whatever else is in the include.

 
WHRoeder:

No. Once you define something it's available from that point on.

You can create a library (one compiled unit) and then create a include file with the #import ex4. Only the function definitions can be seen plus whatever else is in the include.

I haven't gotten around to #import yet. I'm still experimenting with #include.

Am I right that #import will allow me to use a function from the library anywhere after the #import statement (like the #include statement)? Which means that I still don't have a variable whose scope is the include file it's initialized in and nowhere else.

I'm reaching the conclusion that the only way to have a variable scoped to the include file it's initialized in, is to make sure that the #include statement is at the bottom of the mq4 file that #includes it (IOW there is no code following the #include).