Union reserved word missing???

 

According to https://docs.mql4.com/basis/types/classes  union is a reserved word. However, when I try to use it, the compiler doesnt recognise it. I have build 1090.


Screenshot

Structures, Classes and Interfaces - Data Types - Language Basics - MQL4 Reference
Structures, Classes and Interfaces - Data Types - Language Basics - MQL4 Reference
  • docs.mql4.com
The structure name can't be used as an identifier (name of a variable or function). It should be noted that in MQL4 structure elements follow one another directly, without alignment. In C++ such an order is made to the compiler using the following instruction: If a structure contains variables of the string type and/or object of a dynamic...
 

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Особенности языка mql5, тонкости и приёмы работы

fxsaber, 2017.04.27 13:38

template <typename T>
class CASTING
{
public:
  template <typename T1>
  static const T Casting( const T1 &Value )
  {
    union CAST
    {
      T1 Value1;
      const T Value2;

      CAST( const T1 &Value)
      {
        this.Value1 = Value; // a custom operator can spoil everything
      }
    };

    const CAST Union(Value);

    return(Union.Value2);
  }
};

#define _C(A, B) CASTING<A>::Casting(B)

void OnStart()
{
  MqlTick Tick = {0};
  
  Tick = _C(MqlTick, Tick); // Tick = (MqlTick)Tick;
}
 
HarriMQL5: According to https://docs.mql4.com/basis/types/classes  union is a reserved word. However, when I try to use it, the compiler doesnt recognise it. I have build 1090.

Your code complies just fine in a script (with/without property strict.)


Reason: