Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. no out-of-line virtual method definitions
Forum Updated to NodeBB v4.3 + New Features

no out-of-line virtual method definitions

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 4.0k Views 2 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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

    Hi, this struct

    struct InterfaceA {
        virtual void Clean() {}
        InterfaceA() {}
        virtual ~InterfaceA() {}
    };
    

    emits the warning

    warning: 'InterfaceA' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit
    

    Can someone explain how to resolve?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    jsulmJ 1 Reply Last reply
    0
    • mrdebugM mrdebug

      Hi, this struct

      struct InterfaceA {
          virtual void Clean() {}
          InterfaceA() {}
          virtual ~InterfaceA() {}
      };
      

      emits the warning

      warning: 'InterfaceA' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit
      

      Can someone explain how to resolve?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mrdebug See https://stackoverflow.com/questions/28786473/clang-no-out-of-line-virtual-method-definitions-pure-abstract-c-class?rq=1

      // B::x() is inline in the class definition.
      
      struct B {
          virtual void x() {
          }
          virtual ~B() {
          }
      };
      

      If you move the destructor body to the cpp file the warning should disappear.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        Perfect and now

        .h
        struct DefaultStructInterface {
            DefaultStructInterface() {}
            virtual ~DefaultStructInterface();
            virtual void Clean() {}
        };
        
        

        but the line of code

        .cpp
        DefaultStructInterface::~DefaultStructInterface() {}
        

        causes

        warning: definition of implicit copy assignment operator for 'DefaultStructInterface' is deprecated because it has a user-declared destructor
        

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        mrjjM VRoninV 2 Replies Last reply
        0
        • mrdebugM mrdebug

          Perfect and now

          .h
          struct DefaultStructInterface {
              DefaultStructInterface() {}
              virtual ~DefaultStructInterface();
              virtual void Clean() {}
          };
          
          

          but the line of code

          .cpp
          DefaultStructInterface::~DefaultStructInterface() {}
          

          causes

          warning: definition of implicit copy assignment operator for 'DefaultStructInterface' is deprecated because it has a user-declared destructor
          
          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Are you using the clang compiler ?
          anyway, this might be interesting
          https://stackoverflow.com/questions/51863588/warning-definition-of-implicit-copy-constructor-is-deprecated

          1 Reply Last reply
          2
          • mrdebugM mrdebug

            Perfect and now

            .h
            struct DefaultStructInterface {
                DefaultStructInterface() {}
                virtual ~DefaultStructInterface();
                virtual void Clean() {}
            };
            
            

            but the line of code

            .cpp
            DefaultStructInterface::~DefaultStructInterface() {}
            

            causes

            warning: definition of implicit copy assignment operator for 'DefaultStructInterface' is deprecated because it has a user-declared destructor
            
            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @mrdebug said in no out-of-line virtual method definitions:

            is deprecated because it has a user-declared destructor

            This is just the good old rule-of-3 (now became rule-of-5). why don't you just =default them instead of having an empty body to avoid headakes?

            "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
            5

            • Login

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