Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: lloyd!wse@husc6.harvard.edu (Bill Edwards) Newsgroups: comp.sys.sun Subject: Pointer Alignment on Suns Keywords: Software Message-ID: <1082@brazos.Rice.edu> Date: 24 Aug 89 18:59:53 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 21 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 8, Issue 106, message 4 of 15 Let's say I have a pointer to a 'struct foo' which I have typedef'ed to FOOPTR. If I then do something like: FOOPTR foo_ptr = (FOOPTR) malloc ((unsigned) sizeof (struct foo)); at the start of a function, lint on a Sun 4 (SPARC) complains that this line has " possible pointer alignment problems" (lint does *not* give me this meesage on a Sun 3). I wrote a short program to do a sizeof of 'struct foo'. On the Sun 3, 'struct foo' has a size which is not divisible by 4, but on the Sun 4 its size *is* divisible by 4 (has evidently been padded to a long-word boundary). So, my question is, how do I placate lint in this instance? How do I align the pointer? I've tried ensuring that I only malloc memory in chunks in multiple of 4 sizes, but to no avail. Thanks. -- Bill Edwards -- --------------------------------------------------------------------------- Bill Edwards wse%lloyd@husc6.harvard.edu (ARPA) Camex;75 Kneeland St. Boston MA 02111 wse@lloyd.UUCP;edwards@harvunxw.bitnet Tel.: (617) 426-3577 Standard disclaimers