comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: How to make use of a static library and call functions in packages
Date: Tue, 5 Sep 2017 22:06:53 -0700 (PDT)
Date: 2017-09-05T22:06:53-07:00	[thread overview]
Message-ID: <77ae1e61-88c5-4201-9d82-c27cd6b3d799@googlegroups.com> (raw)
In-Reply-To: <32727260-3d7d-42eb-acb0-0eeefb529c2b@googlegroups.com>

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.

      reply	other threads:[~2017-09-06  5:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 20:10 How to make use of a static library and call functions in packages John Smith
2017-09-06  5:06 ` Shark8 [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox