sizeof (struct) differs from Windows and Linux. How can I fix this?
- From: edward hage <edha xs4all nl>
- To: gtk-app-devel-list gnome org
- Subject: sizeof (struct) differs from Windows and Linux. How can I fix this?
- Date: Wed, 29 Dec 2004 18:57:41 +0100
I store data of several large arrays of structs in a binairy file. There are 2 kinds of
Struct 1 has 3 x gchar and 16 doubles and one guint.
Struct 2 has 2 x gchar and 4 doubles.
On linux and Windows the following results are the same:
sizeof(double)=sizof(gdouble) = 8
So netto the size of struct1 should be : 386 and struct 2 172.
Now on Linux the size of the structs are resp. : 388 and 172.
And on Windows XP (cross-compile mingw on Linux): 392 and 176.
Now I don't mind that they are slightly bigger than the sum of their elements, but the
problem is that I can not load the library in Windows (just ported that, loading on Linux
is okay because the binairy file also saves them with size 388 and 172).
I have the following questions:
1) Should the struct be as large as their elements or does the definition of the struct
itself needs some space (and if so, why not for the 172 byte - struct)?
2) How can I read the file in Windows correctly?
Because the sum of the elements on Linux and Windows is the same I have an idea that
guint16 and its friends (always the same size) won't help me in my case. It's the struct
that is different! (I think ...?)
Help is very much appreciated.
] [Thread Prev