Vtable layout and C++ compilers.

N

Neo

Hi Friends,
Is virtual function table layout (VTABLE) is compiler dependent?

Regards
Vikram S
 
G

Gianni Mariani

Neo said:
Hi Friends,
Is virtual function table layout (VTABLE) is compiler dependent?

Yes. There is nothing mandated in the standard about vtables.
 
N

Neo

Mathias said:
Yes.
There is not even a guarantee that a vtable is used.

is such situation, there is not guarantee that polymorphism will work
across component compiled by different compilers and it is against one
of the manjor features of C++.
One thining I would like to mention that all COM (component object
model) component functionality is all based on standard vtable layout
and Microsoft claims that COM specification works for all compilers and
platforms.
 
K

kuoxin

"COM specification works for all compilers and platforms." -- It is
impossible if Microsoft do not make the implementation in platforms.

"Neo :
"
 
R

Rolf Magnus

Neo said:
is such situation, there is not guarantee that polymorphism will work
across component compiled by different compilers and it is against one
of the manjor features of C++.

Which would be...?
You have to look at the ABI that the compiler implements. If it's the same
for both compilers, it should be possible to link together object code
generated by both compilers. Note that there is a whole lot more about the
ABI than just vtables. Think about how values are passed to functions, how
they are returned, how function names are mapped to internal symbol names
(so-called name mangling), how exceptions are thrown and so on.
ISO C++ deliberately doesn't define how that is done to give compiler
implementors more freedom. There are many different hardware/OS
combinations, and the way how to do things best can depend on those.
One thining I would like to mention that all COM (component object
model) component functionality is all based on standard vtable layout
and Microsoft claims that COM specification works for all compilers and
platforms.

I think the only difference here is that the ABI requirement is reduced to a
common C ABI instead of a common C++ ABI.
 
M

Mike Smith

Neo said:
is such situation, there is not guarantee that polymorphism will work
across component compiled by different compilers and it is against one
of the manjor features of C++.
One thining I would like to mention that all COM (component object
model) component functionality is all based on standard vtable layout
and Microsoft claims that COM specification works for all compilers and
platforms.

It is possible to implement an API that supports the COM specification,
that will work on any given compiler or platform. That doesn't that COM
is supported natively by all compilers or platforms. AFAIK, it is only
"natively" supported on Windows, by the Microsoft (and Intel?) compilers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top