Date: Mon, 10 Mar 1997 15:37:19 +1030 (CST) From: Michael Smith <msmith@atrad.adelaide.edu.au> To: zellion@cyberwind.com (Jeffery T. White) Cc: freebsd-hackers@freebsd.org Subject: Re: Structure member alignment Message-ID: <199703100507.PAA03884@genesis.atrad.adelaide.edu.au> In-Reply-To: <199703100410.UAA17876@shell.wco.com> from "Jeffery T. White" at "Mar 9, 97 08:18:41 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
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 [[
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703100507.PAA03884>