From owner-freebsd-hackers Sun Mar 9 21:07:40 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id VAA05697 for hackers-outgoing; Sun, 9 Mar 1997 21:07:40 -0800 (PST) Received: from genesis.atrad.adelaide.edu.au (genesis.atrad.adelaide.edu.au [129.127.96.120]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id VAA05690 for ; Sun, 9 Mar 1997 21:07:35 -0800 (PST) Received: (from msmith@localhost) by genesis.atrad.adelaide.edu.au (8.8.5/8.7.3) id PAA03884; Mon, 10 Mar 1997 15:37:19 +1030 (CST) From: Michael Smith Message-Id: <199703100507.PAA03884@genesis.atrad.adelaide.edu.au> Subject: Re: Structure member alignment In-Reply-To: <199703100410.UAA17876@shell.wco.com> from "Jeffery T. White" at "Mar 9, 97 08:18:41 pm" To: zellion@cyberwind.com (Jeffery T. White) Date: Mon, 10 Mar 1997 15:37:19 +1030 (CST) Cc: freebsd-hackers@freebsd.org X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Jeffery T. White stands accused of saying: > I am writing a client server system with FreeBSD as the client. I would > like the clients [Windoze] to communicate with the server by sending > packets which are actually structures whose definitions both systems use. > In Windows the structure member alignment can be controlled using the > pack(x) pragma. so they can be byte/word/whatever aligned. > > 1. Is there a way to control this in FreeBSD? > > 2. If not is there a standard way [byte/word/etc.] that FreeBSD does this > that I can count on across all CPUs [386/486/Pentium]. Is this something > that might change in the future? > > 3. Maybe some other compiler might do the trick? > > I know what I am writing would likely be difficult to port to other OSes. What you are trying to do is Bad. You should define a wire format using a set of types (eg. XDR) that are guaranteed to be platform-transparent, and then use local techniques for converting to/from this format. I would suggest 'man xdr' on a BSD box as a good place to start. If you're too lazy to do this, then look at the 'attribute __packed' extension to gcc. -- ]] Mike Smith, Software Engineer msmith@gsoft.com.au [[ ]] Genesis Software genesis@gsoft.com.au [[ ]] High-speed data acquisition and (GSM mobile) 0411-222-496 [[ ]] realtime instrument control. (ph) +61-8-8267-3493 [[ ]] Unix hardware collector. "Where are your PEZ?" The Tick [[