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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b29ea596843b99f5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.227.230 with SMTP id sd6mr6434762pbc.8.1332756217755; Mon, 26 Mar 2012 03:03:37 -0700 (PDT) Path: z9ni3233pbe.0!nntp.google.com!news2.google.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: help bridging C and Ada Date: Mon, 26 Mar 2012 10:03:37 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Date: Mon, 26 Mar 2012 10:03:37 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="DkTdSjxOCm6DqG+Uf7eArg"; logging-data="24196"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ISK4shzBBeuyy1D1igd3PBTMmsR6AYfk=" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:iJ7mIqoHleA7z6rJMvhn43D3KDg= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-03-26T10:03:37+00:00 List-Id: On Sun, 25 Mar 2012 06:37:02 -0700, Patrick wrote: > I am having some luck with gnat's -fdump-ada-spec feature and I can use > it to integrate simple C functions I have written. > > However when I try to bind large libraries like gstreamer I end up with > a sort of dependency hell. -fdump-ada-spec-slim just generates the one > spec file but when I try to build with the generated spec, I get errors > about other spec files missing. First : how many errors? Probably (hopefully) only a few, or from only a few further dependencies. > Without the slim option I get about 100 > specs. I tried to "with" them all but I ended up with more errors about > circular dependencies. Only "with" what you need. One of the REALLY STRONG points about Ada is that YOU get to control what is visible and accessible in your program. As opposed to the complete mess that a couple of #includes can get you in C/C++. The huge binding you get with -fdump-ada-spec is just that mess made explicit... I would use -fdump-ada-spec in one folder, just for reference. Then use -slim in my project, and bring across the LEAST you can get away with from the -fdump-ada-spec folder to cover the missing dependencies. (The extra functions can be added to the gstreamer_slim.ads file, or a new gstreamer_extra.ads file, rather than adding complete files from - fdump-ada-spec if you wish. That gives you more control) This partly amounts to writing your own binding, as Simon suggested. The other part is to create a package with Ada procedures and functions to interface to gstreamer, and use ONLY those functions everywhere else in your code. Then only that package needs to interface to the C code. > that was with with Gstreamer and I had others errors when I tried the > same process with gtk. For GTK, there is already an Ada binding - representing a lot of work in itself - gtkada. The Glade GUI builder tool understands gtkada so it can do a lot of the work for you, though not everybody likes it, some want more control over the interface than Glade gives. One point of warning about -fdump-ada-spec : it may still be a work in progress. It does a great job of interfacing to C, but some of the more advanced features of C++ give it problems - it has a good try at processing templates for example, but you have to finish the job. (I had to write dummy C++ code to instantiate each templated function I needed, so that the C++ compiler would actually generate code for them, to prevent linker errors. It didn't seem to understand they were being called from Ada.) - Brian