Re: C structure analyzer ("Reflection" in C?)

Norbert Berzen <norbert@dune.gia.rwth-aachen.de>
30 Jul 1999 22:17:54 -0400

          From comp.compilers

Related articles
C structure analyzer ("Reflection" in C?) phollingsworth@sbsintl.com (1999-07-19)
Re: C structure analyzer ("Reflection" in C?) jsgray@acm.org.nospam (Jan Gray) (1999-07-20)
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)
| List of all articles for this month |
From: Norbert Berzen <norbert@dune.gia.rwth-aachen.de>
Newsgroups: comp.compilers
Date: 30 Jul 1999 22:17:54 -0400
Organization: Aachen University of Technology (RWTH)
References: 99-07-063 99-07-103 99-07-126
Keywords: C, tools

Jerry Pendergraft wrote:


>The actual layout of a structure is largely up to the specific compiler,
>for such things as alignment, which in turn is controlled by
>
>#pragma pack n
>
>All of this makes the output you would get VERRRY non portable anyway
>even from one compile run to the next.


This depends on the code generated by the tool. The code needs not to
have hardwired layout information in it. It could generate C/C++ code
which gets linked together with the application. This code executed
during application startup phase could dynamically extract layout
information solely based on simple prep macros as `offsetof()' and
builtin operators as `sizeof()' and some slightly trickier ones
(e.g. to extract layout information of virtual bases). We developed
such kind of tool as part of a persistent object store for C/C++.
Basically our tool is a C++ compiler frontend with three different
backends:


1) A backend which mostly reflects its input. The input gets somewhat
      augmented by special constructors and friend declarations.


2) A backend which generates C++ source to extract layout information
      (This code gets linked together with the code generated by (1)).


3) A backend which synthesizes database type layout information.


The code generated by the tool should be portable across different
compilation environments since it does not make any assumptions on the
compiler's type layout. With the one exception that virtual base classes
are assumed to be represented as some kind of pointers. But AFAIK all
standard C++ compilers match this assumption.


Greetings
--
Norbert


Post a followup to this message

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