Converting an array of bytes to a ulong?

 

How can I convert

uchar bytes[8];

to a  ulong ?

 
 #include <TypeToBytes.mqh> // https://www.mql5.com/ru/code/16280

void OnStart()
{
  uchar bytes[8];
  
  ulong Value = 0;  
  _W(Value) = bytes;
}
 
fxsaber #:

great, I'll check it out

 
fxsaber #:

I am using MT5.. not sure what version but fairly recent.


I got an error something like "initialization for array sequence needed"


for 

STRUCT_READ<T1> Res = {0};

so it would not compile.. there was also some other error further down that I forget.


both went away when I changed it to = {}; 

I have not tested the code yet ... I'm guessing this is ok 

 
Alternatively
template<typename From, typename To>
void reinterpret_cast(const From& f, To& t){
   union _u{   From from;  const To to;   } u;  u.from=f;   t=u.to;
}
 
ycomp #:

I got an error something like "initialization for array sequence needed"

In the codebase, updated versions of the sources can only be obtained by manually clicking on MQ5/MQH-files.

Reason: