Related articles |
---|
[2 earlier articles] |
Re: C structure analyzer ("Reflection" in C?) pmai@acm.org (1999-07-21) |
Re: C structure analyzer ("Reflection" in C?) kst@cts.com (Keith Thompson) (1999-07-23) |
Re: C structure analyzer ("Reflection" in C?) jerry.pendergraft@endocardial.com (Jerry Pendergraft) (1999-07-28) |
Re: C structure analyzer ("Reflection" in C?) norbert@dune.gia.rwth-aachen.de (Norbert Berzen) (1999-07-30) |
Re: C structure analyzer ("Reflection" in C?) kst@cts.com (Keith Thompson) (1999-07-30) |
Re: C structure analyzer ("Reflection" in C?) dibyendu@mazumdar.demon.co.uk (Dibyendu Majumdar) (1999-07-30) |
Re: C structure analyzer ("Reflection" in C?) denne@aps.rwth-aachen.de (Volker Denneberg) (1999-07-30) |
Re: C structure analyzer ("Reflection" in C?) atrn@zeta.org.au (1999-08-01) |
From: | Volker Denneberg <denne@aps.rwth-aachen.de> |
Newsgroups: | comp.compilers |
Date: | 30 Jul 1999 22:45:30 -0400 |
Organization: | Aachen University of Technology (RWTH) |
References: | 99-07-063 99-07-103 |
Keywords: | C, tools |
phollingsworth@sbsintl.com writes:
> > that uses a large number of C structures. The exchange supplies C
> > header files that describe structures which define the format of the
> > input and output messages. These header files provide structures that
> > define the message format of blocks of bytes that are sent to, and
> > received from, the exchange.
> >
> > Does anybody know of a tool that I could use that converts the C
> > structure definitions into some other source file that has each data
> > member name, byte offset, size etc so that I could make a program to
> > dynamically compose these "structures"?
What about the compiler itself ?
#define OFFSET( struct, member) unsigned( ((struct*)NULL)->member) -
NULL)
// print member name, size and offset:
#define DUMP( os, struct, member) \
os << #member <<" : size=" << sizeof(member) << "\n" \
<< : ofs =" << OFFSET( struct, member) "\n" \
main()
{
struct S { int a,b; char c[10];} // or any other struct
DUMP( cout, S, a);
DUMP( cout, S, b);
DUMP( cout, S, c);
}
or something like that. Should print your table
volker
Return to the
comp.compilers page.
Search the
comp.compilers archives again.