Features of the mql5 language, subtleties and tricks - page 64

 
Koldun Zloy:

If you mean MQL, it has no alignment.

If you mean C++, struct B is better.

Although in any case in C++ alignment is up to the programmer.


The MQL reference also says about alignment)

but what placeholder should you use in Variant B, for 7 bytes?

 

You don't need any fillers.

 
Koldun Zloy:

You don't need any fillers.


Why not when it comes to leveling?

 
Konstantin:

Why not when it comes to alignment?


Trust me.

 
Konstantin:

Why not when it comes to alignment?

The help is all about alignment.
 
Artyom Trishkin:
The help is all about alignment.

How does this apply to my question?

 
Koldun Zloy:

Believe me.

OK

 
Artyom Trishkin:
The reference describes everything about the alignment.

Please note that in MQL5 the structure elements follow each other directly without alignment. In C++, such an instruction is given to the compiler using the

#pragmapack(1)

If you want to make another alignment in a structure, you should use auxiliary "filler" members of appropriate sizes.

 
Alexey Volchanskiy:

Please note that in MQL5 the structure elements follow each other directly without alignment. In C++, such an instruction is given to the compiler using the

#pragmapack(1)

If you want to make another alignment in a structure, you should use auxiliary members "fillers" of required size.

Well, I know what's written in help and when alignment is needed and when it's not.
 
Alexey Volchanskiy:

Please note that in MQL5 the structure elements follow each other directly without alignment. In C++, such an instruction is given to the compiler using the

#pragmapack(1)

If a different alignment in a structure is required, auxiliary "filler" members of the required size should be used.


Alexey, what do you think should be done in my question?

Reason: