From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8bfa37a97c46a2a5 X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: Keeping Ada and C data structures in sync Date: 1999/05/21 Message-ID: <7i4lvs$gin$1@nnrp1.deja.com>#1/1 X-Deja-AN: 480644738 References: <37459F82.BB2DB17@bbn.com> X-Http-Proxy: 1.0 x30.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Fri May 21 22:16:30 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-05-21T00:00:00+00:00 List-Id: In article <37459F82.BB2DB17@bbn.com>, Fred Roeber 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.---