public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* packed structures
@ 2003-12-08 14:01 Frank Cornelis
  2003-12-10  7:51 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Cornelis @ 2003-12-08 14:01 UTC (permalink / raw)
  To: gcc-bugs; +Cc: Frank Cornelis

Hi,

When I mark a structure with __attribute__((packed)) and that structure
has inner-structs, these inner-structs no longer are packed. The correct
semantics for this would be that they inherit this packed property since
people only want to use the packed attribute to model system structures
like for example my pci_slot_entry_struct. (See below for the example)
Thus the entire structure and all its sub-structs need to be packed.

Please CC me,
Frank.



#include <stdio.h>

struct pci_slot_entry_struct {
        unsigned char pci_bus;
        unsigned char pci_device;
        struct {
                unsigned char link;
                unsigned short irq_bitmap;
        //} __attribute__((packed)) ints[4];
        } ints[4];
	unsigned char physical_slot;
        unsigned char reserved;
} __attribute__((packed));


int main() {
	printf("sizeof %d\n", sizeof(struct pci_slot_entry_struct));
	// should be 16
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-10  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-08 14:01 packed structures Frank Cornelis
2003-12-10  7:51 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).