"constant expected" compiler error -- but it's a constant!!!

 

WTF


Anyone know why MQL4 doesn't recognize a constant as a constant?

Or is it telling me "constant" when it means "literal"? 

I don't understand why it doesn't like constants.

 
skeptic23Anyone know why MQL4 doesn't recognize a constant as a constant? Or is it telling me "constant" when it means "literal"? I don't understand why it doesn't like constants.
You cannot use a "constant variable" for the default value. You have to use a "constant" (aka "literal").
 
skeptic23: I don't understand why it doesn't like constants.
  1. It likes constants. You are passing a constant variable. Pass a literal.

  2. Or use the preprocessor.

    #define csConstStr "this is a constant"
    #define ciConstINT 0
    void COMPILES(string sString=csConstStr …
  3. Or internalize it with placeholders.

    const string csConstSTR …;
    const int    ciConstInt …;
    void INTERNALIZED(string sStr="DEFAULT", int iInt=EMPTY){
       if( sString == "DEFAULT") sStr = csConstStr;
       if( iInt    == EMPTY)     iInt = ciConstInt;

 
William Roeder:
  1. It likes constants. You are passing a constant variable. Pass a literal.

  2. Or use the preprocessor.

  3. Or internalize it with placeholders.


HAHA! Thanks man. Right side =/= left side, thanks for making the connection for me. Forgot all about #define.