Path: utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!columbia!close.cs.columbia.edu!ji From: ji@close.cs.columbia.edu (John Ioannidis) Newsgroups: gnu.gcc Subject: packed structures in GCC 1.36? Message-ID: <6632@columbia.edu> Date: 14 Nov 89 04:37:47 GMT Sender: news@columbia.edu Reply-To: ji@close.cs.columbia.edu (John Ioannidis) Distribution: gnu Organization: Columbia University Department of Computer Science Lines: 38 Hi! This topic has probably been discussed in the past, but I haven't been reading gnu.gcc lately. So, suppose I have the following structure: struct _foo { char b1; short w1; short w2; char b2; }; On my machine (a 386 machine running 386/ix (System V R3.2)), the size of _foo is eight bytes, with a "filler" byte between b1 and w1 and another after b2. This is fine, and there are good reasons for doing it. However, when I'm using that structure to access device registers from a device that's memory-mapped (using a pointer that's of type pointer-to-struct-_foo and setting it to the base of the mapped area), I'm in trouble. My system compiler has an option (-Zp1) and the equivalent #pragma directive (#pragma pack) that will force the structure fields to be packed and get the size of the structure to be 6. But for reasons beyond my control I cannot use it -- somebody else wrote the bulk of the code I have to use in ANSI-C, complete with function prototypes and pointers to void! I'd rather not hack a couple of thousand lines of code if there is a way to do it with gcc. And yes, I know about unprotoize, but it won't do the trick! Thanks in advance, /ji In-Real-Life: John "Heldenprogrammer" Ioannidis E-Mail-To: ji@cs.columbia.edu V-Mail-To: +1 212 854 5510 P-Mail-To: 450 Computer Science \n Columbia University \n New York, NY 10027