Download MetaTrader 5

Casting between structures is no longer admitted?

To add comments, please log in or register
giovi61
16
giovi61  

Hello to everyone,

I have encountered problems with the code written before the build versione 1599 of Mediaeditor. The code for casting between structures is no longer accepted.

What I'm saying is verifed. I still have a version of Metaeditor build 1562 and if I compile the following code is regularly compiled:

struct str1
  {
   long    l;
  };

struct str2
  {
   int     low_part;
   int     high_part;
  };

void OnStart()
  {
    str1 s1;
    str2 s2;

    s1.l = 256;
    s2= (str2) s1; //This is compiled without any problems
    
    s2= s1;        //This is compiled but with implicit casting notification
 } 

By compiling the same code with the updated versione of the metaeditor (build 1599) I get this error message:

s2=s1; //cannot cast 'str1' to 'str2'   

s2=(str2) s1; //'=' - illegal operation use

Now I would like to see if this is a bug for the metatrader or it was decided to implement a different casting form, especially for Union operations between structures that were not explicitly contemplated but could be realized as described in this documentation:
https://docs.mql4.com/basis/types/casting

Personally I need this feature on indicators that are very important to me

Do you know anything about it?

Typecasting - Data Types - Language Basics - MQL4 Reference
Typecasting - Data Types - Language Basics - MQL4 Reference
  • docs.mql4.com
Typecasting - Data Types - Language Basics - MQL4 Reference
Taras Slobodyanik
18465
Taras Slobodyanik  

read about "Union"

https://www.mql5.com/en/docs/basis/types/classes

Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
  • www.mql5.com
Language Basics / Data Types / Structures, Classes and Interfaces - Reference on algorithmic/automated trading language for MetaTrader 5
giovi61
16
giovi61  
Taras Slobodyanik:

read about "Union"

https://www.mql5.com/en/docs/basis/types/classes


Thank you!!!
To add comments, please log in or register