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. Suppressing warning "unused parameter". How?
Qt 6.11 is out! See what's new in the release blog

Suppressing warning "unused parameter". How?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 5 Posters 11.1k 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by
    #1

    Suppressing warning "unused parameter". How?

    JonBJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      https://doc.qt.io/qt-5/qtglobal.html#Q_UNUSED

      "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
      • B bogong

        Suppressing warning "unused parameter". How?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @bogong
        Without knowing which compiler you are using?

        If you want to use the Qt macro, Q_UNUSED(var), as per https://doc.qt.io/qt-5/qtglobal.html#Q_UNUSED.

        1 Reply Last reply
        4
        • B Offline
          B Offline
          bogong
          wrote on last edited by
          #4

          Got it. Thx. Issue closed.

          1 Reply Last reply
          1
          • qwasder85Q Offline
            qwasder85Q Offline
            qwasder85
            wrote on last edited by
            #5

            If you're a cool guy, you can comment out the variable name in the function header:

            CoolGuyClass::coolFunction(int /*im_useless*/)
            
            HoMaH 1 Reply Last reply
            0
            • qwasder85Q qwasder85

              If you're a cool guy, you can comment out the variable name in the function header:

              CoolGuyClass::coolFunction(int /*im_useless*/)
              
              HoMaH Offline
              HoMaH Offline
              HoMa
              wrote on last edited by
              #6

              @qwasder85 : That is how I would do it and wondered, why the MACRO exists. Today I found a use case: If a variable is unused only in release but used in debug build!
              I just wanted to share ...

              1 Reply Last reply
              0

              • Login

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