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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d0fcd3db00d6036 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-30 07:40:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: "extern" procedure in ada Date: 30 Sep 2002 10:37:14 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1033397257 4579 128.183.220.71 (30 Sep 2002 14:47:37 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 30 Sep 2002 14:47:37 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:29428 Date: 2002-09-30T14:47:37+00:00 List-Id: "Bernard Azria" writes: > I am looking for the equivallent of an "extern" definition procedure in > C for ADA. > > In other words, how could I define an external procedure to my program > without "withing" the package where it is defined ( I have only the "obj' > and the "ali" file of this procedure in a library) I gather you are trying to use a library that you don't have source for? Be careful not to violate your license to use the library. In order to call any subprogram from Ada, you need the specification of the subprogram; the parameter types and return type. If you have the source code of the subprograms in Ada, you have the subprogram specifications. If you don't have the source code (your case), you need to write the specifications yourself, and tell the compiler to get the bodies of the subprogram from the library. pragma Import is precisely what you need to use for this task. For a library package, it is usually convenient to group the specifications in an Ada package. The package spec contains all the subprogram specs, and all the 'pragma Import' statements. If you are only calling a few subprograms from one place, putting the subprogram specifications in the same package where you are calling them makes sense. > Would it be an kind of : pragma import ( ADA, procedure_name ) Yes, exactly. Although, if the library .o is compiled by a different compiler than your code, this is not guarranteed to work. You might need your vendor to provide an "Ada_GNAT" convention. -- -- Stephe