Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Member Function Pointers Between Modules

Tags:

c++

Just a curiosity question! This seems to suggest that member function pointers are in fact different sizes pending compiler and compile options used, and this seems to suggest that function pointers are passed just fine between modules, so what about member function pointers? I mean with all the hassles that are already presented in passing data between modules it would seem rather silly to even attempt this? Or what about scenarios involving static libraries? If two different compilers are used am I wrong to assume that any scenario involving the passing of a member function pointer would be fruitless?


2 Answers

If you use two different compilers, then unless they have compatible ABI (application binary interface), you cannot sensibly mix-and-match any object code created by them, whether or not member function pointers are involved.

like image 55
Chris Jester-Young Avatar answered Nov 09 '25 04:11

Chris Jester-Young


Member function pointers are quite different beasts from function pointers. They must encode not only the function pointer to the member function, but must also encode the the correct type for the member function, so that the run-time knows how to call the member-function. This is very dependent on how the compiler implements classes, and that implementation certainly changes between compiler vendors, and often changes within compilers based on how the compiler is invoked.

like image 35
SingleNegationElimination Avatar answered Nov 09 '25 05:11

SingleNegationElimination



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!