我需要在 g++ 内联汇编中使用模板类成员的地址(作为编译时常量值)。可以这样表达吗? (我认为我需要 T<U>::x
的损坏名称)。
template < typename U >
struct T {
static int x;
};
template < typename U >
void f () {
asm ("somecommand T<U>::x");
}
最佳答案
假设您使用的是 linux,则可以使用 nm。
nm --demangle foo.o 为您提供符号的 demangled 名称 nm --no-demangle foo.o 为您提供符号的错位名称。
然后您可以比较这 2 个文件的输出,以将经过修饰的名称与经过修饰的名称进行匹配。
关于c++ - g++ 模板名称修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4085591/