Given this interface:
struct ISomething
{
virtual void __stdcall DoSomething() = 0;
};
Can the application call DoSomething on a concrete object returned from a dll or shared object safely, even when the compilation settings are different?
(Assume __stdcall is #defined to nothing on a non-Visual Studio compiler.)
When you say ‘object’ are you, in fact, referring to a pointer to object in question? I’m assuming so, since you very-well cannot create an ISomething due to the pure virtual decls.
So if you mean:
then it will work so long as both caller and implementor agree on the calling convention, packing of structured parameters if there are any, etc. Said-conventions are declaration-based, and are contractually enforced by the implementer+caller. Nasty things happen if you fail to define this as part of the declarative contract.
Is such a thing common in practice? Absolutely. The entire COM-side of all the WIN32 api code I often use is most-assuredly not compiled with the same various compilation settings I used on a regular basis. But the contract I get from the header decls ensures I use the proper conventions to make it work. Those declarations are, in fact, ensuring my compilation agrees with the requirements to make the call a success.
I hope I didn’t misunderstand your question.