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

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

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

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

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

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

  MetaWare High C++ for OS/2 supplies the "Align_Members(n)" directive,
  which can be used either on the command line or in the source text
  (via a pragma directive).

  However, the most portable means of packing structures is not to use a
  directive or command line option, but to use the "_Packed" keyword. It
  is recognised by all C++ compilers except for Borland's (incidentally,
  MetaWare High C++ supplies an "_Unpacked" keyword).

  e.g.

    #if defined(__BORLANDC__)
    #   pragma option -a1
    #else
        _Packed
    #endif
    struct tagname {
           //
           // ...
           //
    } ;
    #if defined(__BORLANDC__)
    #   pragma option -a.
    #endif

  > JdeBP <
___
 X MegaMail 2.10 #0:
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
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: 440/4 141/209 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™.