qt-interest@trolltech.com
[Top] [All Lists]

[OT] Binary compatibility (was: Subclassing [C++ stuff])

Subject: [OT] Binary compatibility was: Subclassing [C++ stuff]
From: Till Oliver Knoll
Date: Fri, 18 Mar 2005 10:51:24 +0100
>>>I think I have to disagree here. The usage of a d pointer *does*
>>>help
>>>with keeping BC, as you can freely add and delete members from it
>>>without affecting the signature of the class, or so I understood
>>>from the documents
>>
>>Hmmm, I have never heard of such a "Signature of a class" thing. I
>>know that methods have a signature (return type, type and number of
>>arguments), but never heard of such a thing for a class. Therefore
>>you might be right ;)
>
>
> It's not a 'signature of a class', it's simply that the number and type of
> data members determines the size of a class, i.e. how much memory an
> instantiated object requires.

Ah yes, that makes perfectly sense.

I'm just curious here since I'm pretty unfamiliar with binary compatibility (BC):

So far I thought that BC means: As long as I don't change the (signature of) public methods and only add new public methods (but don't remove existing ones), that is I only mess around with the internal implementation by adding/removing private members etc., I still have BC. That is when I build my new shared lib (DLL) the linker will still happily find the public methods/functions and hence my new DLL is binary compatible with the old one.

Now the restriction of the size of the instance of a class as mentioned above seems to be only important (at first sight) when I want to store somehow the memory footprint of this class on disk, and want to be able to read this footprint later on from disk and reconstruct the state of this instance.

But as long as I only have code like:

  Foo *foo = new Foo();

I shouldn't have to worry about the actual size of instance foo, no?


Ahhh... just now I could think of a possible problem:

  void Bar::bar() {
    Foo foo;
  }

That is when I _statically_ allocate the instance foo. Now when I dynamically link with the new DLL which implements class Foo and the size of Foo has changed, then I would run into trouble, right?


What is the "official" definition of BC anyway?


Would be really interested in answers ;)

Thanks, Oliver

--
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>