[Qt-interest] Library binary compatibility issue

Thiago Macieira thiago at kde.org
Tue May 25 12:44:13 CEST 2010


Em Terça-feira 25 Maio 2010, às 12:00:44, Giacomo S. escreveu:
> Il giorno ven, 21/05/2010 alle 18.43 +0200, Thiago Macieira ha scritto:
> > Em Sexta-feira 21 Maio 2010, às 14:27:20, Giacomo S. escreveu:
> > >  I thought that reimplementing a virtual method declaring its
> > > 
> > > implementation as non virtual would have removed the virtual
> > > behaviour...
> > 
> > Once virtual, it's virtual forever. So the "virtual" keyword is optional
> > in overriding.
> > 
> > But if you get the method signature wrong, instead of overriding, it
> > simply shadows the original virtual method. This is something that C#
> > got right and the original C++ didn't, but C++0x allows for fixing.
> > 
> > That is, when you write a virtual function, you declare whether it's a
> > new virtual, or whether you're overriding a virtual. Then the compiler
> > can tell you when you think you're declaring a new one but you're
> > actually overriding, or when you think you're overriding but you're not.
> 
> That's all good, thanks. But what about binary compatibility in this
> case:
> 
> class Reader
> {
>   ...
>   protected:
> 	void configure(const TVariant&); /* standard configure() implementation */
> }
> 
> class Label : public QLabel, public Reader
> {
> 	...
> 	protected:
> 		void configure(const TVariant&) ; /* reimplement configure */
> }
> 
> if I make configure() virtual in class Reader:
> 
> class Reader
> {
>   ...
>   protected:
> 	virtual void configure(const TVariant&); /* in version 2 I want it virtual
> */ }
> 
> and in Label
> 
> class Label : public QLabel, public Reader
> {
> 	...
> 	protected:
> 		virtual void configure(const TVariant&) ; /* implement refresh */
> }
> 
> is the library binary compatible with applications using Label??

No.

The change in Reader was not binary compatible. Therefore anything using 
Reader (including Label and all of Label's users) has broken.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100525/e174cd08/attachment.bin 


More information about the Qt-interest-old mailing list