trick for suppressing warnings

To add comments, please log in or register
Bill Morris
287
Bill Morris  

I got tired of compiling include files and seeing the 'warning "someFunction" is not referenced and will be removed from the exp-file'. By the time I get to the script that uses them all, the list is so long I have to scroll to bottom to see if there are any errors. So I created a bogus start() function in the include files.

int start()
{
   int i;
   double d;
   datetime dt;
   string s;

   function1(s, dt);        // functions in #included files
   function2(i, d, dt);     // parameters to match the function parameters
   function3();
   // etc.
}

This gets rid of the warnings, so I can easily see any errors.

When the include file is completed and error free, I will comment out the bogus start() function. I wouldn't want the final ex4 to contain ALL the functions in ALL the #included files, I will only want the functions that are used.

In addition, I will do my best to have all the code int the mq4 start() function be calls to functions in an #include file, so that I don't need to debug the start() function. That way I can do the same thing in the mq4 file during development, and when I'm finally finished I'll comment out the bogus calls to functions, so the ex4 will be as small as possible.

Does anyone know of any reason why this is a bad idea?

William Roeder
18697
William Roeder  
FoxGuy:
I got tired of compiling include files and seeing the 'warning "someFunction" is not referenced and will be removed from the exp-file'. By the time I get to the script that uses them all, the list is so long I have to scroll to bottom to see if there are any errors.
If you get to the warning, there are NO errors.
Bill Morris
287
Bill Morris  
WHRoeder:
If you get to the warning, there are NO errors.

Unfortunately, that's not always true.

I just typed in "hi" with no semicolon into an include file where global variables are defined. When I compiled, I got the "warning 'hi' - expression on global scoped not allowed" and below it the "error 'hi' - variable not defined".

If I read in the dictionary that errors were always above warnings I might feel differently, but right now I feel I have to scroll to the bottom of the list of warnings to make sure there are no errors.

William Roeder
18697
William Roeder  
If you get to the not used warning, there are NO errors.
Bill Morris
287
Bill Morris  
WHRoeder:
If you get to the not used warning, there are NO errors.

That makes sense to me, and I would bet a little money on it being true, but I would not want to assume that it will ALWAYS be true unless MetaTrader confirms that it will always be that way.

In other languages we get warnings from the developers (like Microsoft) that they do not guarantee that any undocumented properties would behave the same way in future versions. It is one of the complaints that some programmers have about Microsoft - they build something into their programs but don't document them, and won't confirm that they will keep them.

Is there somewhere that I can confirm that MetaTrader will always put "not used" below errors?
To add comments, please log in or register