This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049C: Actual content of class member function pointer data

Part Number: TMS320F280049C

Hi all,

I have a pretty detailed question because we stumbled upon it when working with function pointers. As expected regular function pointers are handled as 2 word/32Bit values. When working with member function pointers the size of a pointer increases to 4 words. We can already see that the second part is used for virtual function pointers to indicate that the function is virtual by beeing 0 if it is a regular function and 1 if it is a virtual function. If it is a virtual function the pointer itself does not contain the function address but only the offset inside the vtable as far as we understand.

There are probably many ways to show it but here is one to understand what I mean:

class T_Test
{
public:
    int32_t m_a;

    int32_t add(int32_t b);
    virtual int32_t sub(int32_t b);

    typedef int32_t (T_Test::*FunctionPointer)(int32_t);
};


int32_t T_Test::add(int32_t b) {return m_a+b;};
int32_t T_Test::sub(int32_t b) {return m_a-b;};

int main(void)
{
    T_Test TestInstance;
    T_Test* TestInstancePointer = &TestInstance;

    TestInstance.m_a = 10;

    T_Test::FunctionPointer pfuncAdd = &T_Test::add;
    T_Test::FunctionPointer pfuncSub = &T_Test::sub;

    int32_t arrAdd[sizeof(pfuncAdd)/2];
    memcpy((void*) arrAdd, (void*) &pfuncAdd, sizeof(pfuncAdd));

    int32_t arrSub[sizeof(pfuncSub)/2];
    memcpy((void*) arrSub, (void*) &pfuncSub, sizeof(pfuncSub));


    __asm(" ESTOP0");
}

Most of it is already clear but are there any other things stored inside this second double word of the member function pointer? Is there any detailed description of this?

I did not find any detailed information inside the "C28x Embedded Application Binary Interface" sprac71b or any other document I found. If there is one I am happy for a hint.

Best regards
Wolfgang