switch, case, and const int

 

I don't know if this is a bug or not.

I read that in case there must be a constant value. 

I tried to define some constant int value, and put it into case statement like this:

const int MENU_SHOW 1;

//...

switch (menu_action) {

//...

case MENU_SHOW:
            ObjectSetInteger(0,prefix+"Edit",OBJPROP_TIMEFRAMES,OBJ_ALL_PERIODS);
            printf("menu L (1)");
            break;

//...         
}

 What was confusing was that mql5 compiled ok.

But what I wrote doesn't work.

It must be really a constant like in the manual.

Wouldn't mql5 refuse to compile in the case above? 

Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
 
#define MENU_SHOW 1
 

Thank you.

We will check it. 

 
stringo:

Thanks for suggestion.

I thought of #define from c, but I didn't arrive to try it.

Good it's possible.