How to instruct the compiler to create an alias for a virtual function?

See this question for background.

Basically, I have the following class definition

class  MyClass {
    virtual int foo4(double, int);
};

Is there a way to instruct the compiler to generate two characters that will be allowed for foo4? That is, I want that if the executable asks the dynamic linker to allow _ZN7MyClass4foo4Edi(a symbol for MyClass::foo4(double, int)) and some other symbol (let _ZN7MyClass9reserved1Ev, a symbol for MyClass::reserved1()), the dynamic linker will allow up &MyClass::foo4(double, int). I use pretty modern GCC on Linux.

+5
source share
2 answers

In C ++, it looks like this:

class  MyClass {
    int foo5(double, int) __attribute__((alias("_ZN7MyClass4foo4Edi")));
    virtual int foo4(double, int);
};

int MyClass::foo4(double d, int i)
{
}
+1
source

gcc "alias" .

int reserved1() __attribute__((alias ("_ZN7MyClass4foo4Edi")));

... , , (a) , , : . . , ; , .

+3

All Articles