TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BALOG PAL
from: LEE KIRBY
date: 1997-12-31 16:20:00
subject: Extra bytes

 LK> The way I count, this structure should be only 190 bytes, but if I do
 LK> a sizeof( fMsg), it reports 192!
 BP> What compiler do you use?
DJGPP for DOS.
 BP> The structure members may get "packed", adjusted to appear on word or
 BP> dword boundaries. Or the structure is padded to have size multiple of
 BP> 2, 4, 8, etc. This make access to members faster on most processors,
 BP> while on others you _must_ align some entities to be accessible.
 BP> (For example on SPARC or PA-RISC processors if you try to read a long
 BP> that is not aligned on an address multiple of 4, you get a bus error and
 BP> a coredump. :)
Yikes!  That sounds like what our old tape dumping program written in FORTRAN
is doing occasionally!
 BP> Many current compilers have #pragma pack() that let the programmer
 BP> controlmember alignment in the functions, but they work differently in 
the
 BP> different compilers and even in slightly different versions of the same
 BP> comiler.  There may be also be switches to the comiler 
 BP> for a global setting.
I'll look into #pragma, and any alignment switches.
Thanks for your help!
--- Maximus 3.01
---------------
* Origin: Sirius BBS * Portland, OR (503) 291-1908 * V.34 (1:105/24)

SOURCE: echomail via exec-pc

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™.