This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: name mangle function?


On Jun 11, 2001, Steve Boswell <sboswell@bbn.com> wrote:

> would be to have access to a function that, given a class/method in the
> C++ source, will give me a null terminated string representing the
> mangled symbol name as produced by the compiler.
> Is there such a function in gcc?  

Nope.  Think namespaces, nested classes, argument types, etc, and
you'll see it's not that simple.  Besides, dlsym would only be useful
for static methods (you can't use the pointer dlsym would return to
call a non-static method).

In general, the advice I give to people who want to dlopen C++
libraries is to define a library interface with extern "C" functions
(or static methods), or with global variables of object type
containing pointers to methods.  Neither extern "C" functions nor
global variables are subject to name mangling.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]