* How to make use of a static library and call functions in packages
@ 2017-08-30 20:10 John Smith
2017-09-06 5:06 ` Shark8
0 siblings, 1 reply; 2+ messages in thread
From: John Smith @ 2017-08-30 20:10 UTC (permalink / raw)
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? What about inside of a project file?
- 2 - How can I call a function/procedure in the said static library when the function/procedure is in a package? Do I just call only the public methods?
If there is a sample piece of code, that'd be awesome.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to make use of a static library and call functions in packages
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
0 siblings, 0 replies; 2+ messages in thread
From: Shark8 @ 2017-09-06 5:06 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-06 5:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox