Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Default special member binary compatibility

Default special member binary compatibility

Scheduled Pinned Locked Moved Unsolved C++ Gurus
6 Posts 3 Posters 1.8k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #1

    Hi
    if I have a class:
    header:

    class Foo : public QObject{
    Q_OBJECT
    public:
    Foo(QObject* parent = nullptr);
    ~Foo();
    };
    

    Source

    Foo::Foo(QObject* parent = nullptr)
    :QObject(parent){}
    Foo::~Foo() = default;
    

    Can I change the destructor to

    Foo::~Foo(){
    bar();
    }
    

    without breaking binary compatibility?

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Gut feeling says "no binary compatibility break" but I don't trust it too much. I guess easiest would be to bake Foo into a library, do the change and check if some code using that library will still work after swapping the lib.

      (Z(:^

      1 Reply Last reply
      1
      • K Offline
        K Offline
        Konstantin Tokarev
        wrote on last edited by
        #3

        Why on earth would it break? Binary compatibility is about interfaces, not implementation, and interface didn't change

        VRoninV 1 Reply Last reply
        0
        • K Konstantin Tokarev

          Why on earth would it break? Binary compatibility is about interfaces, not implementation, and interface didn't change

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @Konstantin-Tokarev said in Default special member binary compatibility:

          Why on earth would it break?

          If you don't have a destructor at all (i.e. you leave it implicitly default) and you add it later then you binary compatibility is broken. My question is, is the result different if I make it explicitly default?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          K 1 Reply Last reply
          0
          • VRoninV VRonin

            @Konstantin-Tokarev said in Default special member binary compatibility:

            Why on earth would it break?

            If you don't have a destructor at all (i.e. you leave it implicitly default) and you add it later then you binary compatibility is broken. My question is, is the result different if I make it explicitly default?

            K Offline
            K Offline
            Konstantin Tokarev
            wrote on last edited by
            #5

            @VRonin said in Default special member binary compatibility:

            If you don't have a destructor at all (i.e. you leave it implicitly default) and you add it later then you binary compatibility is broken

            That's wrong. Compatibility is broken if you add virtual destructor to the class which didn't have one. However, in your case implicit destructor is already virtual, because Foo inherits QObject

            VRoninV 1 Reply Last reply
            1
            • K Konstantin Tokarev

              @VRonin said in Default special member binary compatibility:

              If you don't have a destructor at all (i.e. you leave it implicitly default) and you add it later then you binary compatibility is broken

              That's wrong. Compatibility is broken if you add virtual destructor to the class which didn't have one. However, in your case implicit destructor is already virtual, because Foo inherits QObject

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              @Konstantin-Tokarev said in Default special member binary compatibility:

              That's wrong

              Ok, I was told the opposite and I have the maximum respect for your and David's opinion so I don't know who to believe anymore :(

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved