I have noticed that sizzeof() on my program structure is different on x86 and x64 platform. This is becaue of bytes padding. Due to one requirement (where my application talks between cross arch m/c), i need to make sure that target should get the same size of structure what sender had send through a nammedpipe (in my case, i can not read pipe again for remaining data..). I need a way in C++ if i can disable/enable padding safely or strip padding bytes before using sizeof() operator on that structure.
Thanks..
[EDIT | CONCLUSION]: just an input for others who try to seek solution for similar issue. Tried a lot many stupid things to get around this issue but one possible solution mentioned here created the problem in another way, debugging of which time-taking. The best option to this problem i could find out is to use serialization and deserialization methods as ‘R..’ has mentioned below.
If you type #pragma pack(1) before your structure it should disable padding. This works on both visual studio and gcc. You probably also want to use #pragma pack(push) and #pragma pack(pop) to save and restore the previous padding rules.
For example: