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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.102.193 with SMTP id a184mr936367ywc.202.1504674413542; Tue, 05 Sep 2017 22:06:53 -0700 (PDT) X-Received: by 10.36.211.15 with SMTP id n15mr238633itg.5.1504674413492; Tue, 05 Sep 2017 22:06:53 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!h15no47587qta.1!news-out.google.com!p6ni109itp.0!nntp.google.com!127no127234itw.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 5 Sep 2017 22:06:53 -0700 (PDT) In-Reply-To: <32727260-3d7d-42eb-acb0-0eeefb529c2b@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.113.16.86; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 76.113.16.86 References: <32727260-3d7d-42eb-acb0-0eeefb529c2b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <77ae1e61-88c5-4201-9d82-c27cd6b3d799@googlegroups.com> Subject: Re: How to make use of a static library and call functions in packages From: Shark8 Injection-Date: Wed, 06 Sep 2017 05:06:53 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2824 X-Received-Body-CRC: 3346081026 Xref: news.eternal-september.org comp.lang.ada:47942 Date: 2017-09-05T22:06:53-07:00 List-Id: On Wednesday, August 30, 2017 at 2:10:30 PM UTC-6, John Smith wrote: > Hi all, > > I came across this example in rosetta code: > > http://rosettacode.org/wiki/Call_a_function_in_a_shared_library#Ada > > After making some very simple libraries (static and shared), I have two questions: > - 1 - How can the static libraries be included in a binary? This is a function of the linker: it takes the static libraries and integrates them together into its output (usually the executable, though you could output other libraries, static or dynamic). > What about inside of a project file? That's specific to the toolchain being used, not Ada as a language. > - 2 - How can I call a function/procedure in the said static library when the function/procedure is in a package? This is what the Import pragma/aspect does, it signals to the compiler (and linker) that the particular function being defined is actually referencing some external function. -- Importing an uppercase function: Function Uppercase( Input : String ) return String with Import, Convention => Ada, External_Name => "sucf"; -- Exporting an uppercase function: Function To_Upper_Case( Input : String ) return String with Export, Convention => Ada, External_Name => "sucf"; --... implementation in package body. > Do I just call only the public methods? "public" has nothing to do with this at all, there's no reason you couldn't export private methods. (Import/Export is orthogonal to visibility, and also to tagged-types [ie OOP] -- none of these has any real impact on any of the others.) > If there is a sample piece of code, that'd be awesome. See the above.