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,