Subject: to pack or not to pack :=)
From: [email-masked] ("Pedro A. Aranda Guti\irrez")

20 Dec 1996 12:07:58 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (Win95; I)
Original-To: [email-masked]
Original-Sender: [email-masked]

beta 17.1 still shows the same behaviour when it
finds chars in structures: it aligns the structure
to the next short boundary:

You still need the __attribute__((packed))

----------------------------------------------------

#include <stdio.h>
#include <stddef.h>

typedef struct {
  char ch;
  short sh;
  int   i;
  long  l;
} /* __attribute__((packed)) */ test;

int main(int argc,char **argv)
{
  printf("ch @ %d\n"
	 "sh @ %d\n"
	 "i  @ %d\n"
	 "l  @ %d\n",
	 offsetof(test,ch),
	 offsetof(test,sh),
	 offsetof(test,i),
	 offsetof(test,l));
}

-------------------------------------

ch @ 0
sh @ 2
i  @ 4
l  @ 8

-- 

     +--------------------------------------------------------+
     |  ####   Pedro Andres Aranda Gutierrez                  |
     |  ####                                                  |
     |  ####   Telefonica I+D;  Network Interconnection Div.  |
     |  ====   C./ Emilio Vargas, 6    E-28043 Madrid, Spain  |
     |  ====   e-mail : [email-masked]                           |
     |  ====   Tlf 34-1-337 47 02      FAX 34-1-337 45 02     |
     +--------------------------------------------------------+
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".