Re: structure layout in C

bliss@sp64.csrd.uiuc.edu (Brian Bliss)
Fri, 15 May 1992 18:59:18 GMT

          From comp.compilers

Related articles
structure layout in C muller@src.dec.com (1992-05-11)
Re: structure layout in C macrakis@osf.org (1992-05-13)
Re: structure layout in C stephen@estragon.uchicago.edu (1992-05-13)
Re: structure layout in C bliss@sp64.csrd.uiuc.edu (1992-05-15)
| List of all articles for this month |

Newsgroups: comp.compilers
From: bliss@sp64.csrd.uiuc.edu (Brian Bliss)
Keywords: C, tools, FTP
Organization: UIUC Center for Supercomputing Research and Development
References: 92-05-066
Date: Fri, 15 May 1992 18:59:18 GMT

muller@src.dec.com (Eric Muller) writes:
|> I'd like to find an algorithm to determine the layout of C structure
|> declarations. This algorithm should be parameterized so that it can
|> work for as many machines as possible. The algorithm used in GCC
|> would have been a perfect candidate, if only I could understand it
|> (without reading all of gcc).


Well, once again I'll make a push for my super-duper C interpreter /
symbol table scanner. ftp to sp2.csrd.uiuc.edu and get ae.tar.Z (remember
to set mode to binary). uncompress, untar. look at the file
"ae/src/ae_s_u.c", and the function ae_set_struct_offsets() basically
performs what you're asking, which is pretty simple until you throw
bit-fields into the picture. Anyway, the offsets it produces agree with
the Alliant FX/8 C compiler (2 byte words, 4 byte ints, big-endian),
Alliant FX/2800 C compiler (4 byte words, 4 byte ints, little endian), and
Sparc C compiler (4 byte words, 4 byte ints, big endian) (at least if I
haven't broken it for one machine when porting to the other), so it's
pretty well "parameterized".


Can you understand it without reading the rest of the source???
It's worth a look...


bb
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.