From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32364 invoked by alias); 8 Dec 2003 14:01:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 32353 invoked from network); 8 Dec 2003 14:01:19 -0000 Received: from unknown (HELO trappist.elis.UGent.be) (157.193.204.1) by sources.redhat.com with SMTP; 8 Dec 2003 14:01:19 -0000 Received: from tom.elis.UGent.be (tom.elis.UGent.be [157.193.205.192]) by trappist.elis.UGent.be (8.11.6/8.11.6) with ESMTP id hB8E1HJ30192; Mon, 8 Dec 2003 15:01:17 +0100 Subject: packed structures From: Frank Cornelis To: gcc-bugs@gcc.gnu.org Cc: Frank Cornelis Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Mon, 08 Dec 2003 14:01:00 -0000 Message-Id: <1070892057.9579.27.camel@tom> Mime-Version: 1.0 X-SW-Source: 2003-12/txt/msg00934.txt.bz2 List-Id: 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 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 }