comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Keeping Ada and C data structures in sync
Date: 1999/05/21
Date: 1999-05-21T00:00:00+00:00	[thread overview]
Message-ID: <7i4lvs$gin$1@nnrp1.deja.com> (raw)
In-Reply-To: 37459F82.BB2DB17@bbn.com

In article <37459F82.BB2DB17@bbn.com>,
  Fred Roeber <froeber@bbn.com> wrote:
> I have a question that has probably been asked before (even though I
> haven't been able to find any references to). The project I am on has
> some code written in C and some in Ada. The two parts of the program
> have to communicate by passing data structures. Does anyone know of a
> good way to keep data structure declarations consistent between C and
> Ada?
>
> We have wondered about several solutions:
> - using a translator to derive C include files from Ada

I had pretty good success on one project writing a
special-purpose converter from Fortran declaration files (with a
specific, defined  format) to C header files. For that project I used
lex/yacc. It took about 3 weeks to write and debug, and worked very
well.

One big source of lost debugging hours in this kind of system is a
mismatch between interface files. The trick is to get the running of the
tool inserted into the build process so that the new translation is made
and compiled against automaticly whenever the source interface file is
changed. A good "make" wizard can set this up for you. For an additional
runtime check, you should consider putting a literal version number of
some kind in the interface.

If you can't trust one side (C or Ada) to stick to a rigid enough format
to keep the translator simple, I suppose you could make up a new
language and write and maintain *two* translators. But that seems like a
lot more work to me.

For this task you may find the OpenToken package (
http://www.telepath.com/dennison/Ted/OpenToken/OpenToken.html ) useful.
Its a hierarchy of Ada95 packages that provide a callable
object-oriented interface for lexical analysis. No precompiler is
involved. It currently only handles token analysis (lex's sphere),
leaving the parsing up to the user. If your parsing needs are simple and
you'd like an Ada implementation for your translator give it a try.

Adding a parsing facility is planned. But it probably won't appear for
at least a couple of months.

--
T.E.D.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




  reply	other threads:[~1999-05-21  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-21  0:00 Keeping Ada and C data structures in sync Fred Roeber
1999-05-21  0:00 ` dennison [this message]
1999-05-21  0:00 ` Larry Kilgallen
1999-05-22  0:00 ` Robert Dewar
1999-05-24  0:00   ` Samuel Mize
1999-05-23  0:00 ` Aidan Skinner
1999-05-23  0:00   ` David Botton
1999-05-23  0:00     ` Bob
1999-05-24  0:00       ` Chris
1999-05-24  0:00         ` David Botton
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox