🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #2325

Re: GCC 2.1 or GCC 2.2.2?

#2325
From: Colin Jensen
Date: Tue, 06 Oct 1992 15:29
27 lines
1607 bytes
In article <1992Oct5.123837.28122@wsl.ie> jja@wsl.ie (John J. Allen) writes:
>Well 2.1 packs struct's automatically and 2.2.2 does not. I have not found
>a way to do this. This is a real pain if you use any system calls.

[Warning: The following applies to gcc/2.  I know nothing about EMXGCC]

The version of gcc 2.2.2 that I am using *does* support packing structs
by using a #pragma option.  ``#pragma pack(n)'' where n is the desired
alignment that you want for structs will cause all structs declared
after the #pragma to be given alignment on n-byte boundaries.

For example, to declare a struct with byte (i.e. packed) alignment, you
could write:
]#pragma pack(1)  /* Start byte alignment */
]struct foo {
]    unsigned char one;
]    long two;		/* This field starts at offset 2 in the struct */
]};
]#pragma pack(4)  /* Restore default quadword alignment for efficiency */

The default if you do not use any pragma statements is pack(4).  It is
advisable to restore pack(4) after you declare everything that needs pack(1).

The OS/2 headers for gcc/2 are *full* of pack pragmas.
-
Colin Jensen
cjensen@ampex.com	ljensen@netcom.netcom.com
Technical Details
Message-ID: <1992Oct6.152907.7326@netcom.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!sdd.hp.com!decwrl!csus.edu!netcom.com!ljensen
References: <46260002@hpcupt3.cup.hp.com> <1992Oct5.123837.28122@wsl.ie>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!sdd.hp.com!decwrl!csus.edu!netcom.com!ljensen
From: ljensen@netcom.com (Colin Jensen)
Subject: Re: GCC 2.1 or GCC 2.2.2?
Message-ID: <1992Oct6.152907.7326@netcom.com>
Organization: Netcom - Online Communication Services (408 241-9760 guest)
References: <46260002@hpcupt3.cup.hp.com> <1992Oct5.123837.28122@wsl.ie>
Date: Tue, 6 Oct 1992 15:29:07 GMT
Lines: 27