Vtable layout and C++ compilers.

Discussion in 'C++' started by Neo, Dec 28, 2006.

  1. Neo

    Neo Guest

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

    Regards
    Vikram S
    Neo, Dec 28, 2006
    #1
    1. Advertising

  2. Neo wrote:
    > Hi Friends,
    > Is virtual function table layout (VTABLE) is compiler dependent?


    Yes. There is nothing mandated in the standard about vtables.
    Gianni Mariani, Dec 28, 2006
    #2
    1. Advertising

  3. Neo wrote:
    > Hi Friends,
    > Is virtual function table layout (VTABLE) is compiler dependent?
    >


    Yes.
    There is not even a guarantee that a vtable is used.
    Mathias Gaunard, Dec 28, 2006
    #3
  4. Neo

    Neo Guest

    Mathias Gaunard wrote:
    > Neo wrote:
    > > Hi Friends,
    > > Is virtual function table layout (VTABLE) is compiler dependent?
    > >

    >
    > 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.
    Neo, Dec 28, 2006
    #4
  5. Neo

    kuoxin Guest

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

    "Neo :
    "
    > Mathias Gaunard wrote:
    > > Neo wrote:
    > > > Hi Friends,
    > > > Is virtual function table layout (VTABLE) is compiler dependent?
    > > >

    > >
    > > 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.
    kuoxin, Dec 28, 2006
    #5
  6. Neo

    Rolf Magnus Guest

    Neo wrote:

    > Mathias Gaunard wrote:
    >> Neo wrote:
    >> > Hi Friends,
    >> > Is virtual function table layout (VTABLE) is compiler dependent?
    >> >

    >>
    >> 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++.


    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.
    Rolf Magnus, Dec 28, 2006
    #6
  7. Neo

    Mike Smith Guest

    Neo wrote:
    > Mathias Gaunard wrote:
    >> Neo wrote:
    >>> Hi Friends,
    >>> Is virtual function table layout (VTABLE) is compiler dependent?
    >>>

    >> 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.


    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.

    --
    Mike Smith
    Mike Smith, Dec 28, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Quansheng Liang
    Replies:
    2
    Views:
    561
    Quansheng Liang
    May 25, 2004
  2. Replies:
    1
    Views:
    571
    John Timney \(MVP\)
    Jun 19, 2006
  3. geletine

    commercial c compilers vs free c compilers

    geletine, Jul 2, 2006, in forum: C Programming
    Replies:
    33
    Views:
    1,312
  4. Neo
    Replies:
    1
    Views:
    341
    Rolf Magnus
    Dec 28, 2006
  5. Ole Nielsby
    Replies:
    15
    Views:
    1,411
    James Kanze
    Oct 15, 2008
Loading...

Share This Page