Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!amdahl!oliveb!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Structure alignment in Manx C Message-ID: <42016@sun.uucp> Date: 16 Feb 88 00:12:21 GMT References: <8802140413.AA17411@cory.Berkeley.EDU> Sender: news@sun.uucp Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 26 Tom Rokicki wrote : > I just tracked down this bug that took me immense amounts of time > to find, and I discovered something about Manx C. I found out that > one of my friends had also run into and wasted hours finding this > anomaly. Specifically, Manx C does not long-word align structures > containing long words! (It also doesn't apparently long-word align > long words.) > Correct-a-mundo! Since the 68000 can load longwords on odd word addresses neither C compiler cares to put them on longword boundaries. It does align them on word boundaries however. So you can very cruftily get around the problem (in the case of the FileInfoBlock that Matt mentioned) like so : short mem[(sizeof(struct FileInfoBlock) >> 1)+1]; struct FileInfoBlock *fi; fi = (struct FileInfoBlock *)(((ULONG)(mem) & 3) ? &mem[1] : &mem[0]); Now, is that gross code or what? --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you.