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. because [[maybe unused]] doesn't work in Qt?
Forum Updated to NodeBB v4.3 + New Features

because [[maybe unused]] doesn't work in Qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 509 Views
  • 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.
  • lincolnL Offline
    lincolnL Offline
    lincoln
    wrote on last edited by
    #1

    I get this warning, because I have cppcheck installed, and it tells me that I don't use the return value of qry, so I put the [[maybe_unused]] attribute, and it gives me an error, it should work, but it doesn't.

    [[maybe_unused]]qry.prepare("SELECT from my db");

    bdcd3c06-7f91-4ada-b063-4df9bec106a7-image.png

    Solitary wolf

    D 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      [[maybe_unused]] is a c++ 17 feature - make sure to compile your code with c++17. So it's a basic c++ problem which has nothing to do with Qt.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • lincolnL lincoln

        I get this warning, because I have cppcheck installed, and it tells me that I don't use the return value of qry, so I put the [[maybe_unused]] attribute, and it gives me an error, it should work, but it doesn't.

        [[maybe_unused]]qry.prepare("SELECT from my db");

        bdcd3c06-7f91-4ada-b063-4df9bec106a7-image.png

        D Offline
        D Offline
        DerReisende
        wrote on last edited by
        #3

        @lincoln It does work if you have set up your project correctly. I am using it within a Qt C++20 project without problems.

        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