Can the vtable offset of a specific virtual function be inspected?
Why? I'd like to be able to detect unintentional binary compatibility breaks (see http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B for what I mean by binary compatibility).
I'm aware of the undocumented and unsupported technique of "/d1reportSingleClassLayout" (http://blogs.msdn.com/b/vcblog/archive/2007/05/17/diagnosing-hidden-odr-violations-in-visual-c-and-fixing-lnk2022.aspx), and I plan to use this technique, but I'd like to also use some simple compile time or run time checks if possible.
There's a good example here. Mind though that you won't be able to retrieve function name, just the address/offset.
It's ugly, non-portable, crufty, etc., but maybe something on this general order would be useful:
To be a bit more portable, you should probably use an array of unsigned char as the second element of the union -- printing that out in a meaningful manner will add a bit more work that I'll leave to you (at least for now).
Inspired by Jerry's answer, I managed to write up this function that can do the same thing for any function signature: