Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!lu!cchd From: CCHD@lure.latrobe.edu.au (Huw Davies - La Trobe University Computer Centre) Newsgroups: comp.unix.aix Subject: Aligned access to c structures (how to avoid) Message-ID: <5053@lure.latrobe.edu.au> Date: 13 Feb 91 16:45:17 GMT Organization: VAX Cluster, Computer Centre, La Trobe University Lines: 36 I have a slight problem with the AIX v3 c compiler (on an RS/6000). The following code doesn't do what I want :-) Please note that this is an example of the error extracted from debugging 6K lines of c code (It took a while to find....). $ more test_struct.c #include struct test { short a; int b; } c; main() { printf("a: %x\nb: %x\nSize of a: %d\n", &c.a, &c.b, (int) &c.b - (int) &c.a); } $ ./test a: 2003e460 b: 2003e464 Size of a: 4 $ I would have liked the difference in address to be 2, not 4. I know that there are efficiency reasons for aligned access, but I would like to be able to override the default. I have searched high and low all over our CD-ROM and can't find an option to the c compiler to force the slow (but nice) way. Huw Davies Computing Services e-mail: cchd@lucifer.latrobe.edu.au