lkml.org 
[lkml]   [1997]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Off-topic
On Wed, 5 Mar 1997, Mike Kilburn wrote:

> > __attribute__((packed))
>
> Does not work. (2.7.2)

Does, if you pack the whole structure.

The below example

struct pak {
char byte;
long dword;
} __attribute__((packed));

xxx (struct pak *pak) {
return sizeof(*pak);
}

Compiled with (gcc-2.7.2.1)

# gcc -S -O2 packed.c

Gives

xxx:
pushl %ebp
movl %esp,%ebp
movl $5,%eax
^^^^

which is (what I guess) just what you want ( sizeof(char) + sizeof(long) ).

Packing the whole structure leads to byte alignment for all members within
the structure, hence you are free to privately align by inserting dummy
byte variables into the structure.

Hans
<lermen@fgan.de>



\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.032 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site