TIP: Click on subject to list as thread! ANSI
echo: tub
to: Bob Jones
from: Bo Simonsen
date: 2003-10-05 19:55:50
subject: Sqfix problem

Hello Bob!

05 Oct 03 06:42, you wrote to me:

 BJ>> Ah....  That would explain it.....  Yes, sizeof() may
 BJ>> not 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..

 BJ> The problem is that sizeof() returns the number of bytes in
 BJ> memory.  By default, structures are not packed.  If the structure was
 BJ> packed, then sizeof() should have worked for reading and
 BJ> writing files.

Oh! I thought so, but I wasn't scure about it.

 BJ> Wes has a define made to allow packing the structures
 BJ> under GCC but not on other compilers where the packing isn't needed.

It's needed for use with fx. OS/2 or Win32, BTW one of my links told that
the user.bbs from a Max/2 can't be readed by Max/Linux

 BJ> Any structure that has more than one item (which it should or you
 BJ> wouldn't have used a structure), and has elements that are not an
 BJ> exact multiple of 4 or 8 bytes may get located on 4 (or 8) byte
 BJ> boundaries, resulting in unused bytes in the structures memory immage.

Ah!

 BJ> So, sizeof() is needed for memory copies, but fail when
 BJ> reading and/or writing binary files in these cases.....

I see :-)

Thanks for the explanation!

Regards,
Bo

--- GoldED+/LNX 1.1.4.7
* Origin: The Night Express, Roennede Dk (2:236/100)
SEEN-BY: 633/267 270
@PATH: 236/100 237/9 20/11 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.