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: Paul Pluzhnikov
Subject: Re: does rtti of gcc support "get object by name at runtime" ?
Date: Wed, 17 Jan 2007 17:45:37 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

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,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

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