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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ed926d4d933b76e3 X-Google-Attributes: gid103376,public From: cgreen@yosemite.atc.com (Christopher Green) Subject: Re: C interface - Apex/Verdix Date: 1997/05/29 Message-ID: <5mjb0u$dhi@newshub.atmnet.net>#1/1 X-Deja-AN: 244676479 References: <338ce5d2.87925678@news.mhv.net> Organization: Advanced Technology Center, Laguna Hills, CA Newsgroups: comp.lang.ada Date: 1997-05-29T00:00:00+00:00 List-Id: In article <338ce5d2.87925678@news.mhv.net>, Paul Van Bellinghen wrote: >Has anyone ever intefaced a C object module with an (Ada83) Ada >program in the Rational Apex or Verdix VadsCross environment? I am >planning to just include the object module in the compilation view and >use the Pragma Interface (C, c-function-name). Will this work? You may also need pragma Interface_Name (c-function-name, "actual-name"); this will account for situations where VADS name-mangling doesn't yield the correct name for the C function. Apex for Ada 83 has pragma Import_Function and pragma Import_Procedure, which combine the effects of these two pragmas, but they are not portable. Apex for Ada 95 has pragma Import, which is portable. For example, you could write a binding to the libc function getenv() as follows: function Getenv (Name : in System.Address) return System.Address; pragma Interface (C, Getenv); pragma Interface_Name (Getenv, Language.C_Subp_Prefix & "getenv"); (Language is a predefined package on VADS that provides the correct prefixes for external names; for example, on SunOS 4 hosts, Language.C_Subp_Prefix is the string "_".) Also, you will need to make sure that the Ada types you use are equivalent to the C types that the C object module is expecting. If you are passing pointers to composite types, you will probably need to write rep specs in Ada to get the compiler to lay out the types correctly. This is easier in Ada 95, where you have the package Interfaces.C. If you have to do a lot of this, it may be worthwhile considering a move to Ada 95. Chris Green Email cgreen@atc.com Advanced Technology Center Phone (714) 583-9119 22982 Mill Creek Drive ext. 220 Laguna Hills, CA 92653 Fax (714) 583-9213