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 Path: g2news2.google.com!news4.google.com!feeder.news-service.com!news2.euro.net!newsfeed.freenet.de!news.teledata-fn.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Interfacing with C Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <250d9b93-13bf-4375-8b35-a1b0a7f74d99@j12g2000vbl.googlegroups.com> Date: Mon, 18 May 2009 13:58:35 +0200 Message-ID: <6i3cwvzndx7y.1j38k2uakyqyp$.dlg@40tude.net> NNTP-Posting-Date: 18 May 2009 13:58:36 CEST NNTP-Posting-Host: 7ee0528d.newsspool2.arcor-online.net X-Trace: DXC=LoEA6g:E57;Tia]Ho99G50A9EHlD;3Yc24Fo<]lROoR1^YC2XCjHcb9d8LUkWUHga2DNcfSJ;bb[5FCTGGVUmh?4LK[5LiR>kg2jdT:X;3_cY< X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:5896 Date: 2009-05-18T13:58:36+02:00 List-Id: On Mon, 18 May 2009 04:29:44 -0700 (PDT), cedric wrote: > I would like to connect a C interface to another software package with > my Ada programs. > > The h-file of the api contains the following pre-processor commands: > > #ifdef SPSSXD_EXPORTS > # define SPSSXD_API __declspec(dllexport) > #else > # if MS_WINDOWS > # define SPSSXD_API __declspec(dllimport) > # else > # define SPSSXD_API > # endif > #endif >From this you should figure out the call convention. It can be either C or stdcall. The rest can be usually ignored. Usually this stuff tells whether the entry point is a reference or else a vector for dynamic run-time linking or else an entry point, when the library itself is compiled, nothing interesting for an Ada client. > Some functions headers are > > SPSSXD_API bool IsBackendReady(); > SPSSXD_API int SetUpFromSPSS(SpssAdapter* anAdapter, SpssXDSmb* > anSmb); > > What do I have to do to get a connection between the C functions and > my Ada program with regard to the commands of the pre-processor? Print the preprocessor output if you are in doubts. Otherwise it could be like this: with Interfaces.C; use Interfaces.C; ... function IsBackendReady return Int; -- C does not have Boolean pragma Import (stdcall, IsBackendReady, "IsBackendReady"); type SpssAdapter is record ... -- Components of struct SpssAdapter end record; pragma Convention (C, SpssAdapter); type anSmb is record ... -- Components of struct anSmb end record; pragma Convention (C, anSmb); function SetUpFromSPSS ( anAdapter : access SpssAdapter; anSmb : access SpssXDSmb ); pragma Import (stdcall, SetUpFromSPSS, "SetUpFromSPSS"); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de