I got the impression that whenever you do one of them:
- Add a new public virtual method
virtual void aMethod(); - Add a new public non-virtual method
void aMethod(); - Implementation of a publicly available pure virtual method from the
virtual void aMethod override; interface virtual void aMethod override;
It actually violated binary compatibility, which means that if the project was built on a previous version of the DLL, now it will not be able to load it if new methods are available.
From what I tested with Visual Studio 2012, none of this breaks anything. Dependency Walker did not report an error, and my test application called the appropriate method.
DLL:
class EXPORT_LIB MyClass { public: void saySomething(); }
Executable:
int _tmain(int argc, _TCHAR* argv[]) { MyClass wTest; wTest.saySomething(); return 0; }
The only undefined behavior that I found was that MyClass implemented a purely virtual interface and from my executable file, I called one of the purely virtual methods, and then I added a new purely virtual method before it was used by my executable. In this case, the Dependency Walker did not report any error, but at run time it actually called the wrong method.
class IMyInterface { public: virtual void foo(); }
In executable file
IMyInterface* wTest = new MyClass(); wTest->foo();
Then I change the interface without restoring my executable
class IMyInterface { public: virtual void bar(); virtual void foo(); }
Now a quiet call to bar() instead of foo() .
Can all my three assumptions be made?
EDIT:
Doing this
class EXPORT_LIB MyClass { public: virtual void saySomething(); }
Exec
MyClass wTest; wTest.saySomething();
Then rebuild the DLL as follows:
class EXPORT_LIB MyClass { public: virtual void saySomething2(); virtual void saySomething(); virtual void saySomething3(); }
Calls the corresponding saySomething()