help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does rtti of gcc support "get object by name at runtime" ?


From: William
Subject: Re: does rtti of gcc support "get object by name at runtime" ?
Date: Thu, 18 Jan 2007 10:20:31 +0800
User-agent: Opera Mail/9.10 (Win32)

On Thu, 18 Jan 2007 09:45:37 +0800, Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> wrote:

William <xx@abc.com> writes:

for example, I have a global object:
        extern Object myobj;

Can gcc get this object by using string "myobj" at runtime??
I know C++ rtti doesnt support this,
but I dont know if gcc can ,

Gcc can't either; but if your platforms has dlsym(3) or its equivalent,
and if the code was compiled and linked with appropriate flags
(which are platform-specific), then you can lookup symbols by name
at runtime.

If you have control over "Object", a much more portable solution
is to have objects "register" themselves in some global map, in
which you can later look them up.

Cheers,

thanks, i am now using the 'register solution' and want to get a better way.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]