From owner-freebsd-questions Fri Apr 3 13:59:53 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA11629 for freebsd-questions-outgoing; Fri, 3 Apr 1998 13:59:53 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from newton.ccs.tuns.ca (root@newton.ccs.Tuns.Ca [134.190.1.4]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA11589 for ; Fri, 3 Apr 1998 13:59:37 -0800 (PST) (envelope-from xiaominy@tuns.ca) Received: from tuns.ca (ipv6-2.ee.Tuns.Ca [134.190.5.72]) by newton.ccs.tuns.ca (8.8.8/8.8.8) with ESMTP id SAA17245; Fri, 3 Apr 1998 18:00:27 -0400 (AST) Message-ID: <352594BA.2E58B3B8@tuns.ca> Date: Fri, 03 Apr 1998 18:02:34 -0800 From: Xiaomin Ye Reply-To: xiaominy@newton.ccs.tuns.ca Organization: Dept. of Electrical & Computer Engineering, Daltech, Dalhousie University X-Mailer: Mozilla 4.02 [en] (Win95; I) MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG, ifair@newton.ccs.tuns.ca, Larry.Hughes@StMarys.ca Subject: bit and byte alignment on FreeBSD? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Dear Sir/Madam, We encountered a strange problem while using FreeBSD. The following structure can be compacted to be 8 bytes by means of cc compiler on Open-VMS platform. But on FreeBSD, 12 bytes will be formed. #pragma nomember_alignment struct example_structure { unsigned type : 3; unsigned c : 1; signed mem1 : 12; signed mem2 : 24; signed mem2 : 24; }; It seems that on FreeBSD the compiler can only provide one, two or four bytes alignment, "type" occupies 1 byte, "c" occupies 1, "mem1" 2 , "mem2" 4 bytes and "mem3" 4 bytes, because is no bit alignment and 3-byte alignment. However, on Open-VMS the compiler can provide the bit alignment, "type", "c" and "mem1" take 2 byte space, and "mem2", "mem3" will occupy 3 bytes respectively. The total space will be only 8 bytes. Is there any solution to this problem? Your kind will be very much appreciated. Regards, Xiaomin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message