Re: How to get the absolute path of the library currently loaded?
bruno.fischel@gmail.com wrote:
I was wondering if there was a way to know the absolute path of the
library "currently running".
There can be. However, it would be a feature of the OS, not of the
language.
In C++ what's "running" is the program, not "the library". The host system
_may_ provide the command with which it was started, in the 'argv[0]' (see
the 'main' function), or it may not, it's up to the system. Many systems
do,
yet some don't.
For example, in my function foo, how can I get the path of the library
containing the definition of foo?
C++ defines the _language_. In C++ you can find the _translation unit_ in
which the *code* is contained (see __FILE__ macro). The rest is platform-
and implementation-specific (and off-topic here).
The library path will be different from the "current directory" (.)
since the current directory will be the directpry of the prgram that
loaded the lib; not the path to the library itself.
All those things are unknown to C++.
Otherwise, do you know fi the STL library provide a "registry service"
(like the java Preferences API)?
Nothing like that in the Standard.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask