Binary Compatibility Workarounds

This page describes some workarounds for keeping binary compatibility in patch releases.

You should read the KDE reference: http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++

Declaring a slot for private classes (d-pointer)

Use a Q_PRIVATE_SLOT:

  1.     class A: public QObject
  2.     {
  3.         Q_OBJECT
  4.         ...
  5.     private:
  6.         Q_PRIVATE_SLOT(d_func(), void myPrivateSlot())
  7.     };
  8.    
  9.     /* in .cpp file */
  10.    
  11.     void APrivate::myPrivateSlot() {...}
  12.    
  13.     #include "moc_a.cpp"

Pitfalls to avoid:

  • Don’t include `a.moc`, but `moc_a.cpp` in your .cpp file
  • Q_PRIVATE_SLOT takes the complete signature of the private slot, not just its name

Categories: