comp.lang.ada
 help / color / mirror / Atom feed
* Keeping Ada and C data structures in sync
@ 1999-05-21  0:00 Fred Roeber
  1999-05-21  0:00 ` Larry Kilgallen
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Fred Roeber @ 1999-05-21  0:00 UTC (permalink / raw)


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
- using some sort of IDL with the appropriate compilers to derive
  C and Ada versions of the structure definitions from the common
  input language

Has anybody had experience/success with either of these approaches. Does
anyone know of some other better method? Thanks for any advice.  Fred
-- 
   |      Fred J Roeber,  BBN Systems & Technologies      |
   |    4 John Clarke Road   Middletown, RI  02842-5202   |
   |          froeber@bbn.com     401-848-3548            |




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-21  0:00 Keeping Ada and C data structures in sync Fred Roeber
@ 1999-05-21  0:00 ` Larry Kilgallen
  1999-05-21  0:00 ` dennison
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Larry Kilgallen @ 1999-05-21  0:00 UTC (permalink / raw)


In article <37459F82.BB2DB17@bbn.com>, Fred Roeber <froeber@bbn.com> writes:
> 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

Ada advocates have produced tools to do the reverse, primarily addressed
at producing Ada bindings to code from Ada-hostile vendors.  The direction
you want may also be available.

> - using some sort of IDL with the appropriate compilers to derive
>   C and Ada versions of the structure definitions from the common
>   input language

David Botton has recently published something that takes this approach
with Ada from a Microsoft input file.  Check Deja.com for posts from
this group within the past two months.

MacOS and VMS quite separately and some time ago selected the second
approach for supporting disparate languages, at least for OS entrypoints.
I know the VMS mechanism has data structure support as an equal goal --
the MacOS tool is less familiar to me.

The VMS tool was developed before Ada, and as a result Ada support
had to be retrofitted, and there was not always a one-to-one mapping
between capabilities of the input language and capabilities of Ada.
While that would not be a problem for your stated goal of supporting
just two languages, I am sure you have considered the problem of what
to do if (for instance by customer edict) you are required in the
future to add another language (let us say LISP, just to make it
non-obvious).

The VMS tool is now on the VMS Freeware disc, and should be portable
(with a little effort) to any operating system with a PL/I compiler.

> Has anybody had experience/success with either of these approaches. Does
> anyone know of some other better method? Thanks for any advice.

I think there is no ideal solution, as computer languages evolve and
add concepts that are unknown in other computer languages.  Whatever
approach you take, make sure you get management buy-in to ensure you
have ongoing maintenance of the tool.  With the second approach this
has been a problem for both Apple and DEC, each of which had programming
staffs probably larger than yours.

Larry Kilgallen




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-21  0:00 Keeping Ada and C data structures in sync Fred Roeber
  1999-05-21  0:00 ` Larry Kilgallen
@ 1999-05-21  0:00 ` dennison
  1999-05-22  0:00 ` Robert Dewar
  1999-05-23  0:00 ` Aidan Skinner
  3 siblings, 0 replies; 10+ messages in thread
From: dennison @ 1999-05-21  0:00 UTC (permalink / raw)


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.---




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-21  0:00 Keeping Ada and C data structures in sync Fred Roeber
  1999-05-21  0:00 ` Larry Kilgallen
  1999-05-21  0:00 ` dennison
@ 1999-05-22  0:00 ` Robert Dewar
  1999-05-24  0:00   ` Samuel Mize
  1999-05-23  0:00 ` Aidan Skinner
  3 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 1999-05-22  0:00 UTC (permalink / raw)


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?

Can you explain precisely what you want to do here, and why
pragma Convention does not meet your needs?


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




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-21  0:00 Keeping Ada and C data structures in sync Fred Roeber
                   ` (2 preceding siblings ...)
  1999-05-22  0:00 ` Robert Dewar
@ 1999-05-23  0:00 ` Aidan Skinner
  1999-05-23  0:00   ` David Botton
  3 siblings, 1 reply; 10+ messages in thread
From: Aidan Skinner @ 1999-05-23  0:00 UTC (permalink / raw)


On Fri, 21 May 1999 18:04:01 GMT, Fred Roeber <froeber@bbn.com> wrote:

>- using some sort of IDL with the appropriate compilers to derive
>  C and Ada versions of the structure definitions from the common
>  input language

This could be a good opportunity to investigate CORBA.

- Aidan (who thinks CORBA has the potential to be ridiculously useful,
but wishes the IDL wasn't quite so C-like, as he hates parenthesis)
-- 
http://www.skinner.demon.co.uk/aidan/
Real men whistle ed commands at 300 baud into a can.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-23  0:00   ` David Botton
@ 1999-05-23  0:00     ` Bob
  1999-05-24  0:00       ` Chris
  0 siblings, 1 reply; 10+ messages in thread
From: Bob @ 1999-05-23  0:00 UTC (permalink / raw)


 
>
>Aidan Skinner wrote:
>> 
 
>> 
>> - Aidan (who thinks CORBA has the potential to be ridiculously useful,
>> but wishes the IDL wasn't quite so C-like, as he hates parenthesis)
 
I agree, that is why CORBA is comes in as part of Java core API's:
org.omg.CORBA. 

If you use Java, programming with CORBA is so easy, (you do not need
to use those MS products as someone suggested to program in corba).

btw, Java and corba are becomming very very popular these days, and
it is good skill to learn.
 
Bob





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-23  0:00 ` Aidan Skinner
@ 1999-05-23  0:00   ` David Botton
  1999-05-23  0:00     ` Bob
  0 siblings, 1 reply; 10+ messages in thread
From: David Botton @ 1999-05-23  0:00 UTC (permalink / raw)


Actually you could design the structures in MS IDL now and use my
prototype COM binding generator to do it. MIDL would generate the C and
TLB file and the BindCOM would generate the Ada Spec from the tlb.
(http://www.adapower.com/com)

David Botton


Aidan Skinner wrote:
> 
> On Fri, 21 May 1999 18:04:01 GMT, Fred Roeber <froeber@bbn.com> wrote:
> 
> >- using some sort of IDL with the appropriate compilers to derive
> >  C and Ada versions of the structure definitions from the common
> >  input language
> 
> This could be a good opportunity to investigate CORBA.
> 
> - Aidan (who thinks CORBA has the potential to be ridiculously useful,
> but wishes the IDL wasn't quite so C-like, as he hates parenthesis)
> --
> http://www.skinner.demon.co.uk/aidan/
> Real men whistle ed commands at 300 baud into a can.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-22  0:00 ` Robert Dewar
@ 1999-05-24  0:00   ` Samuel Mize
  0 siblings, 0 replies; 10+ messages in thread
From: Samuel Mize @ 1999-05-24  0:00 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-dejanews.com> wrote:
> In article <37459F82.BB2DB17@bbn.com>,
>   Fred Roeber <froeber@bbn.com> wrote:
...
>> Does anyone know of a good way to keep data structure
>> declarations consistent between C and Ada?
> 
> Can you explain precisely what you want to do here, and why
> pragma Convention does not meet your needs?

I believe he wants to mechanically ensure that the data structure
definitions are equivalent in both languages, e.g. to prevent (or
at least detect) adding a field to a struct on the C side without
adding it to the record on the Ada side.

Certainly pragma Convention is much better than using rep clauses
to lay out your records, once you have language-level equivalence.

Best,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-23  0:00     ` Bob
@ 1999-05-24  0:00       ` Chris
  1999-05-24  0:00         ` David Botton
  0 siblings, 1 reply; 10+ messages in thread
From: Chris @ 1999-05-24  0:00 UTC (permalink / raw)


In article <7i9urj$23jv@drn.newsguy.com>, Bob says...
 
>I agree, that is why CORBA is comes in as part of Java core API's:
>org.omg.CORBA. 
>
>If you use Java, programming with CORBA is so easy, (you do not need
>to use those MS products as someone suggested to program in corba).
>
>btw, Java and corba are becomming very very popular these days, and
>it is good skill to learn.
 

You can get GNACK, the GNU Ada CORBA kit. to download for linux see:

http://www.cl.cam.ac.uk/~mgk25/linux-ada/

(end of page).

Chris





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keeping Ada and C data structures in sync
  1999-05-24  0:00       ` Chris
@ 1999-05-24  0:00         ` David Botton
  0 siblings, 0 replies; 10+ messages in thread
From: David Botton @ 1999-05-24  0:00 UTC (permalink / raw)


GNACK has a home page now:

http://www.adapower.com/corba

David Botton


Chris wrote:
> 
> In article <7i9urj$23jv@drn.newsguy.com>, Bob says...
> 
> >I agree, that is why CORBA is comes in as part of Java core API's:
> >org.omg.CORBA.
> >
> >If you use Java, programming with CORBA is so easy, (you do not need
> >to use those MS products as someone suggested to program in corba).
> >
> >btw, Java and corba are becomming very very popular these days, and
> >it is good skill to learn.
> 
> 
> You can get GNACK, the GNU Ada CORBA kit. to download for linux see:
> 
> http://www.cl.cam.ac.uk/~mgk25/linux-ada/
> 
> (end of page).
> 
> Chris




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1999-05-24  0:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-21  0:00 Keeping Ada and C data structures in sync Fred Roeber
1999-05-21  0:00 ` Larry Kilgallen
1999-05-21  0:00 ` dennison
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

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