Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Remove warning "unused parameters"

Remove warning "unused parameters"

Scheduled Pinned Locked Moved C / C++ / MFC
c++designhelpquestion
3 Posts 2 Posters 0 Views 1 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.
  • M Offline
    M Offline
    marca292
    wrote on last edited by
    #1

    I have a C++ class that implements a interface (ErrorInterface), because of old design. My class don't uses one of the methods (reset) in this interface but I have added an empty implementation because I don't want the class to be abstract. When I build the project I get warnings "unused parameters 'error'". Can I remove this warning?

    //Interface
    class ErrorInterface
    {
    public:
    virtual void reset(ErrorType error) = 0;
    };

    //.cpp file I have just added the implementation
    //because I don't want MyClass to be abstract
    void MyClass::reset(ErrorType error)
    {
    }

    _ 1 Reply Last reply
    0
    • M marca292

      I have a C++ class that implements a interface (ErrorInterface), because of old design. My class don't uses one of the methods (reset) in this interface but I have added an empty implementation because I don't want the class to be abstract. When I build the project I get warnings "unused parameters 'error'". Can I remove this warning?

      //Interface
      class ErrorInterface
      {
      public:
      virtual void reset(ErrorType error) = 0;
      };

      //.cpp file I have just added the implementation
      //because I don't want MyClass to be abstract
      void MyClass::reset(ErrorType error)
      {
      }

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Either of the following methods will remove the warning -

      void MyClass::reset(ErrorType)
      {
      }

      OR

      void MyClass::reset(ErrorType error)
      {
      error;
      }

      Or you can use the UNREFERENCED_PARAMETER macro which does the same as the second method -

      void MyClass::reset(ErrorType error)
      {
      UNREFERENCED_PARAMETER(error);
      }

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++)

      Polymorphism in C

      M 1 Reply Last reply
      0
      • _ _Superman_

        Either of the following methods will remove the warning -

        void MyClass::reset(ErrorType)
        {
        }

        OR

        void MyClass::reset(ErrorType error)
        {
        error;
        }

        Or you can use the UNREFERENCED_PARAMETER macro which does the same as the second method -

        void MyClass::reset(ErrorType error)
        {
        UNREFERENCED_PARAMETER(error);
        }

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++)

        Polymorphism in C

        M Offline
        M Offline
        marca292
        wrote on last edited by
        #3

        Thanks!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups