Helge Bahmann schrieb:
I have to access C++ symbols in multiple places through their linker names and
wondered if there is something more maintainable than having
to "brain-mangle" the names? What I would need is a builtin that transforms a
name into its mangled representation as string at compile-time.
Essentially I would like to replace something like
__asm__(".set _ZN5media11colorspaces11YUV_CCIR601E,
_ZN5media11colorspaces3YUVE\n"));
with
__asm__(".set " __mangle__(media::colorspaces::YUV_CCIR601E) ","
__mangle__(media::colorspace::YUV) "\n");
(to create a symbol alias) or
dlsym(hdl, "_ZN5media11colorspaces3YUVE");
with
dlsym(hdl, __mangle__(media::colorspaces::YUV));
As far as I could find the only assistance provided with name-mangling is
run-time and only deals with the inverse problem. Does something like this
exist
Hi Helge,
I am afraid something like this doesn't exist. I have been desperately
looking for it as well and asked for it on this list a couple of months ago
(http://gcc.gnu.org/ml/gcc-help/2006-12/msg00107.html) - neither answer nor
success so far :-/
(or is there a good reason why it *doesn't* exist and I should not be
doing what I do?)
Good question. I do not see any reasons why compile-time name
mangling/demangling should not be done. It even does not have to be a
builtin function. At least in situations where you could do without
scope/argument dependent name lookup -- probably 99% of the situations this
feature is desired in practice -- a simple string-level preprocessor might
do it.
If you find anything please let me know. So will I do.
Daniel