[Wine] Re: winelib shared memory problem
wineforum-user at winehq.org
Mon Feb 6 16:16:01 CST 2012
I have solved the problem with faulty read/write of structure, which was created by Server. This article (http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/) helped me a lot in understanding the problem.
Since the Server was compiled in VC++ under windows, it uses different way of storing binary data or being more exact "Data Structure Alignment" than gcc on Linux. As I figured out two main issues that can arise when using structures in different systems are "data alignment" and "data structure padding", which must match on both sides.
Apparently in my case "data structure padding" has matched between VC++ on Windows and wineg++ on Linux. So I haven't added any "#pragma pack(n)" lines into the code.
But "data alignment" was different. Unexpectedly the exact solution was found in wikipedia (http://en.wikipedia.org/wiki/Data_structure_alignment) that came with "-malign-double" option to gcc compiler. By default on Windows "double" and "long double" types are 8-byte aligned and on Linux 4-byte aligned. This option instructs the gcc compiler to use 8-byte alignment for these types.
More information about the wine-users