See this question for the background.
Basically, I have the following definition of a class
class MyClass {
virtual int foo4(double, int);
};
Is there a way to instruct the compiler to generate two symbols that would resolve to foo4
? That is, I want that if an executable asks for the dynamic linker to resolve _ZN7MyClass4foo4Edi
(symbol for MyClass::foo4(double, int)
) and some other symbol (let's say _ZN7MyClass9reserved1Ev
, a symbol for MyClass::reserved1()
), the dynamic linker would resolve both to &MyClass::foo4(double, int)
. I`m using fairly modern GCC on Linux.
In gcc, use the "alias" attribute.
int reserved1() __attribute__((alias ("_ZN7MyClass4foo4Edi")));
... but I believe this will only work in the same object file as (a) definition of the symbol, so I'm not sure it will suit your uses cases: see here. Specifically, it will only be an alias for one version of the virtual call, and won't be inherited by subclasses; additionally, you cannot use it to alias a weak symbol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With