G ++ template name

I need to use the address of a member of the template class in the g ++ inline assembly (as the value of the compile time constant). Can this be expressed? (I think I need a distorted name T<U>::x).

template < typename U >
struct T {
  static int x;
};

template < typename U >
void f () {
  asm ("somecommand T<U>::x");
}
+3
source share
2 answers

Assuming you are using linux, you can use nm.

nm --demangle foo.o gives you demarcated names for your characters nm --no-demangle foo.o gives you malformed names for your characters.

You can then compare the output of these two files to match the search name with the demangulated name.

+1
source

objdump , ( c++filt , , , , spec http://www.codesourcery.com/public/cxx-abi/abi.html mangler mangling , , , ).

0

Source: https://habr.com/ru/post/1772814/


All Articles