* how to init static standalone library with GNAT
@ 2007-09-20 11:24 Agyaras
2007-09-21 10:28 ` Rob Norris
0 siblings, 1 reply; 2+ messages in thread
From: Agyaras @ 2007-09-20 11:24 UTC (permalink / raw)
I am learning Ada right now and wrote a little standalone library as an
exercise. I am using the GNAT system (2007, GPL version from AdaCore)
under SuSE Linux 10.1. The library presents a private type to its
clients, and this type contains a standard map. Here are the relevant
parts of the spec:-
with Ada.Containers.Ordered_Maps;
...
package Lib is
type T is private;
...
private
Map_Pkg is new Ada.Containers.Ordered_Maps(Key_Type, Element_Type);
type T is record
M: Map_Pkg.Map;
...
end record;
end Lib;
When I compile & link the library as dynamic standalone with
auto-initialization, then it works nicely. When I use static linking,
then it crashes when the map is accessed in T. Obviously the map needs
some initialization and auto-init is not done for static libraries (says
so in the manual).
Now, I prefer to use static libraries as in my experience (with other
languages) linking and distributing dynamic libs was always a hassle. My
question is:- can one initialize a standalone static library in the GNAT
system? If yes, then how? Is that solution portable to other compilers?
Thanks for any hints & pointers,
Agyaras
--
"Non est volentis, neque currentis, sed miserentis Dei"
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: how to init static standalone library with GNAT
2007-09-20 11:24 how to init static standalone library with GNAT Agyaras
@ 2007-09-21 10:28 ` Rob Norris
0 siblings, 0 replies; 2+ messages in thread
From: Rob Norris @ 2007-09-21 10:28 UTC (permalink / raw)
On Thu, 20 Sep 2007 13:24:08 +0200, Agyaras <agyaras@kerekerdoe.hu> wrote:
>When I compile & link the library as dynamic standalone with
>auto-initialization, then it works nicely. When I use static linking,
>then it crashes when the map is accessed in T. Obviously the map needs
>some initialization and auto-init is not done for static libraries (says
>so in the manual).
>
>Now, I prefer to use static libraries as in my experience (with other
>languages) linking and distributing dynamic libs was always a hassle. My
>question is:- can one initialize a standalone static library in the GNAT
>system? If yes, then how? Is that solution portable to other compilers?
>
>Thanks for any hints & pointers,
>Agyaras
Perhaps you'll have to add routines Initialise and Is_Initialised.
Then clients *have* to ensure the library initialised before real use.
Not the most elegant solution, but should force things to work.
The initialise rotuine would have to call the internal auto-initiialise (however that is done*).
The Is_Initialised function would have to determine the state somehow*.
*Implementation details left as an exercise for the reader (because I don't know how).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-21 10:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-20 11:24 how to init static standalone library with GNAT Agyaras
2007-09-21 10:28 ` Rob Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox