|
From: Chris W. <ch...@qw...> - 2011-06-20 12:38:04
|
Hi Roman,
On Mon, 20 Jun 2011, Roman Wieczorek wrote:
> I have noticed that vtables generated by mingw are different than
> those from visualstudio.
> The incompatible code is generated by such class.
>
> class Vtable {
> virtual void Overloaded(int) = 0;
> virtual void Overloaded(Vtable&) = 0;
> virtual void Other() = 0;
> };
>
> According to what i found here:
> http://old.nabble.com/Incorrect-vtable-generation-in-MinGW--td15781052.html
> I have made my code compatible using such prepossessing.
As far as I know, the only cross-compiler (standard, supported) use of
vtables is in COM APIs, and as that discussion concluded, COM does not
allow overloading of methods:
"Overloading methods isn't supported by COM. The MIDL compiler won't let
you define an interface with two methods that have same name."
So what is this application of vtables that you're using? If it's COM, is
it an incorrect use of the standard (both in overloading and its use of
references)? Whatever it is, is it sufficiently standardised that you're
actually allowed to mix compilers when using it?
> Is there some compiler option so ming would generate vs compatible
> vtables?
I doubt it, this is the first time I've heard of someone wanting to do
something that involved mixing compilers and not COM and that might not be
prohibited by lack of standardisation between C++ compilers. But you could
ask the GCC developers about adding such an option.
> Maybe there is some other way to make a code compatible, some
> preprocessor macro probably like:
I'm not sure how a simple macro could affect the order that methods are
compiled into a vtable, at least not like that. Perhaps, just possibly, it
might work if it was a variadic macro that is applied to the methods in
question within the class, changing their order.
> Any way I think the problem should be described some where on
> http://www.mingw.org/wiki.
If you do, please describe your use case as well. (what standard you're
adhering to, etc.)
Cheers, Chris,
|