On 07/21/14 17:09, Dmitry Yemanov wrote:
> 21.07.2014 16:32, Alex Peshkoff wrote:
>
>> First of all - formal definition of API is certainly not a set of C++
>> classes. Each firebird interface is a single pointer, pointing to the
>> table of virtual functions that are contained in this interface. First
>> parameter of each function is always a pointer to an interface itself.
>>
>> This definition in plain english may be rewritten in C:
>> struct ISample
>> {
>>        struct VTable
>>        {
>>            void functionOne(ISample* this, Type1 par1, Type2 par2, /*
>> other parameters */);
>>            void functionTwo(ISample* this, TypeA parA, TypeB parB, /*
>> other parameters */);
>>            /* other functions ... */
>>        };
>>
>>        VTable* vTable;
>> };
>   >
>> Such definition of pure virtual interface should work and be correct for
>> any working C compiler.
>   >
>   > [snip]
>   >
>> in C++ we get exactly same binary layout for any known to us C++ compiler.
> Is this really so? This is why I'm asking:
>
> https://gcc.gnu.org/ml/gcc-help/2003-11/msg00257.html

Please pay attention to the year when a question was asked - probably 
this is what Jim mentions about vtable position in the end of an object? 
Anyway such old versions make no practical interest for us.

> http://stackoverflow.com/questions/5712808/understanding-the-vtable-entries
>
> i.e. GCC has a different vtable layout and moreover it's version-dependent.

Ahh - it's related with multiple inheritance and rtti. Luckily we do not 
use both in interfaces.

The test I've written some time ago to check how does interface upgrade 
run at different systems does work with C++ classes as with pure virtual 
interfaces - this is what makes possible to upgrade interface version.

http://web.firebirdsql.org/download/rabbits/alex/checkAbi.tgz

Run
sh build.sh
./ldr

Expected output is:
C1-f1
C1-f2
int 75
C2-f1
C2-f2
C2-f3

I've rechecked it right now starting with
     gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) // was used to 
build FB 1.5,
definitely 32-bit std RH8 layout, and ending with
     gcc version 4.8.2 (GCC) // was used to build FB3 Alpha2
64-bit compiler.
Both work as expected.

> As for Free Pascal, they also reserve 12 bytes at the beginning of the
> vtable, hence the compatibility issue.

12 byte? On 64-bit system?
They are crazy!


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to