在我的 cpp 文件中,我有以下内容:
int A()
{
}
void B_A() __attribute__((alias ("A")));
我收到错误: B_A() 别名为 undefined symbol A; 但是,正如您所注意到的,A 是在此之前定义的。
所以有什么问题!?
最佳答案
来自 the docs :
In C++, the mangled name for the target must be used.
所以,您需要 A
的错位名称,或者您需要给 A
C 链接,这样它的名字就不会首先被错位。
关于c++ - 如何为 C++ 函数定义属性别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7100919/