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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ff38817118c33e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-27 10:59:47 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3B8A8AA8.9B588C2A@raytheon.com> From: Mark Johnson Reply-To: mark_h_johnson@raytheon.com X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.6-3.1smp i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Automatic generation of C bindings References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 27 Aug 2001 13:00:08 -0500 NNTP-Posting-Host: 192.27.48.41 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 998935187 192.27.48.41 (Mon, 27 Aug 2001 12:59:47 CDT) NNTP-Posting-Date: Mon, 27 Aug 2001 12:59:47 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:12472 Date: 2001-08-27T13:00:08-05:00 List-Id: Jano wrote: > Hello all. > > I'm looking for a tool that generates ada specs from c headers to > allow link to c libraries. > Good luck on "automatic translation". The best you will get is something that is "close", but requires a lot of debugging to get it correct. Things that tend to be OK include... - access to external symbols and functions [see caution] - layout of simple data structures The caution on external symbols gets into the use of underscores (_) to prefix symbols in some compilers, symbol crunching on some systems, and so on. You may need to use pragma Import, Export, and Convention (or other compiler specific ones) to make everything right. Problems I've seen include... - macros that manipulate access to the data (e.g., a value is "true" if it is equal to "X" after mask "Y") - functions that use (void*) to pass data dependent on other arguments - the whole argv mechanism - alignment of data - bit and byte order - multiple layers of macros These you are better off doing manually. If you are using gcc on Unix, I recommend... - create a simple C application (test.c) that does what you want - gcc -C -E -dD [other switches here] test.c > test.output - gcc -C -E -dM [other switches here] test.c | sort > test.macros [I assume other C compilers have similar options for capturing preprocessor output] The file "test.output" captures the expanded source code w/ comments. The file "test.macros" captures the just the macro definitions. This plus, some understanding of how your C and Ada compiler lays out data, passes parameters, and so on will give you the clues you need to do this task. Better yet, if there is some specific Ada to C bindings you are looking for, ask for that & someone should be able to help you (e.g., Florist for Posix bindings). --Mark