|structure layout in C email@example.com (1992-05-11)|
|Re: structure layout in C firstname.lastname@example.org (1992-05-13)|
|Re: structure layout in C email@example.com (1992-05-13)|
|Re: structure layout in C firstname.lastname@example.org (1992-05-15)|
|From:||email@example.com (Brian Bliss)|
|Keywords:||C, tools, FTP|
|Organization:||UIUC Center for Supercomputing Research and Development|
|Date:||Fri, 15 May 1992 18:59:18 GMT|
firstname.lastname@example.org (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...
Return to the
Search the comp.compilers archives again.