delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/08/12/20:32:12

From: tstokes AT pacbell DOT net (Tom Stokes)
Subject: Re: packed structures
12 Aug 1998 20:32:12 -0700 :
Message-ID: <00a201bdc60f$71a9bb80$8947aace.cygnus.gnu-win32@TomStokes>
Mime-Version: 1.0
To: "Tom Stokes" <tstokes AT pacbell DOT net>, "CYGWIN32" <gnu-win32 AT cygnus DOT com>

Thanks to all that replied. This does work. The size is 9.

typedef struct HeaderTag {
    ULONG          HeaderLength;
    CHAR             PackingType;
    USHORT         NumRows;
    USHORT         PackedSize;
    } __attribute__ ((packed)) HeaderType, *pHeaderType;


   Tom Stokes

If anyone is interested, this is from manpages:
----------------------------------------------------------------------------
----------------------------------------
packed
The packed attribute specifies that a variable or structure field should
have the
smallest possible alignment--one byte for a variable, and one bit for a
field,
unless you specify a larger value with the aligned attribute.

Here is a structure in which the field x is packed, so that it
immediately follows a:

struct foo
{
  char a;
  int x[2] __attribute__ ((packed));
};



-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019