TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jonathan de Boyne Pollard
from: Mike Bilow
date: 1996-01-04 08:55:54
subject: read from cd rom

Jonathan de Boyne Pollard wrote in a message to Mike Bilow:

MB>
  > 32-bit compilers pack by default on doubleword boundaries.
MB>

 JdBP> No.  Borland C++ 2.0 for OS/2 defaults to byte alignment. 
 JdBP> So does   Watcom C++ 10.5 (I'm surprised at you, Mike. 
 JdBP> (-:).  MetaWare High C++   for OS/2 aligns a structure
 JdBP> according to the most stringent alginment requirement of
 JdBP> its members.

Watcom C++ definitely aligns by default on doubleword boundaries.  I
checked the documentation and you are right that it claims to align by
default on byte boundaries, but this seems to be wrong when checked against
generated code.  I suspect that this changed at some point in the compiler
and was forgotten in the documentation.  In my opinion, any 32-bit compiler
should default to doubleword alignment, and GCC gets a fair amount of speed
from doing so.

MB>
  > Most compilers allow "#pragma pack(1)" to achieve this, or
  > require a command line option.
MB>

 JdBP>   The only C++ compilers that support "#pragma pack()" are
 JdBP> IBM VisualAge   C++ and Watcom C++ (and even then it doesn't
 JdBP> mean the same for both   compilers, since Watcom C++ and IBM
 JdBP> VisualAge C++ have different   defaults).

I consider the "#pragma pack()" syntax to be quasi-standard by
now, since it goes back to ancient Microsoft C.  Like many other arbitrary
symbols and conventions, this became the de facto standard.

 JdBP>   Borland C++ for OS/2 requires you to use the -a command
 JdBP> line option,   which can be changed within a source file
 JdBP> using "#pragma option -a". 

Borland, although preferring the "#pragma option" syntax,
certainly supports "#pragma pack()" and even uses this form in
their own header files.
 
-- Mike


--- 
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515
SEEN-BY: 712/517 628 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 396/1 270/101 712/515 711/808 809 934

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