Subj : Sqfix problem To : Bo Simonsen From : Bob Jones Date : Sun Oct 05 2003 07:42 am BS>> Of some reason sizeof(XMSG) doesn't give the exact BS>> size, the problem did Squish also have but i fixed it BS>> there, but #define'ing XMSG_SIZE in msgapi, it was BS>> right after the porting of maximus.. BJ> Ah.... That would explain it..... Yes, sizeof() may not BJ> work in all environments now..... :( BS> Well I just don't understand it, because it does BS> normally work under Linux, maybe it's the arrays.. The problem is that sizeof() returns the number of bytes in memory. By default, structures are not packed. If the structure was packed, then sizeof() should have worked for reading and writing files. Wes has a define made to allow packing the structures under GCC but not on other compilers where the packing isn't needed. Any structure that has more than one item (which it should or you wouldn't have used a structure), and has elements that are not an exact multiple of 4 or 8 bytes may get located on 4 (or 8) byte boundaries, resulting in unused bytes in the structures memory immage. So, sizeof() is needed for memory copies, but fail when reading and/or writing binary files in these cases..... Take care..... Bob Jones, 1:343/41 --- Maximus/2 3.01 * Origin: Top Hat 2 BBS (1:343/41) .