Path: utzoo!utgpu!water!watmath!clyde!rutgers!sdcsvax!ucsdhub!hp-sdd!hplabs!well!ewhac From: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Newsgroups: comp.sys.amiga Subject: Re: Byte/word/long alignment Message-ID: <4974@well.UUCP> Date: 12 Jan 88 22:28:23 GMT References: <4366@garfield.UUCP> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Distribution: na Organization: The CIA: Third-World Governments Destabilized While-U-Wait. Lines: 28 In article <4366@garfield.UUCP> john13@garfield.UUCP (John Russell) writes: >If I want to create an auto-initialized array of UBYTES, and then later >access each 4 bytes as a longword, can I ensure that the array is longword >aligned in some portable way (eg by placing it immediately after some other >32-bit global variable)? Why don't you simply create it as an array of longwords, then access it as bytes with a coerced pointer? ULONG foo[] = { 1, 2, 3, 4, 5, ...n }; bar() { UBYTE *bp; bp = (UBYTE *) foo; . . . } No muss, no fuss, guaranteed alignment (if the compiler supports it). _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab -- The Guy in The Cape ihnp4!ptsfa -\ \_ -_ Recumbent Bikes: dual ---> !{well,unicom}!ewhac O----^o The Only Way To Fly. hplabs / (pronounced "AE-wack") "Work FOR? I don't work FOR anybody! I'm just having fun." -- The Doctor