Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. remove qt headers warning with cmake
QtWS25 Last Chance

remove qt headers warning with cmake

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 2 Posters 918 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.
  • M Offline
    M Offline
    Mwoua_Leddar
    wrote on last edited by
    #1

    Hello,
    im using cmake and visual studio for my project, but I got warnings from qt headers. For example:
    Warning C4127 conditional expression is constant C:\Qt\5.15.1\msvc2019_64\include\QtCore\qvector.h 796

    Is there a way to use
    find_package(Qt5 COMPONENTS Core Sql REQUIRED)
    and declare them as system headers?

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

      @Mwoua_Leddar said in remove qt headers warning with cmake:

      Is there a way to use
      find_package(Qt5 COMPONENTS Core Sql REQUIRED)
      and declare them as system headers?

      No since MSVC does not (yet) support 'system headers', but at least they found out at the end of 2017 that it's maybe useful: https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
      But as always they decided that it has to be different than the other compilers so ...

      /edit: and looking at the code this warning is really strange when emitted in a template... wonder how the msvc devs would be able to write it without triggering a warning here

      if (QTypeInfo<T>::isComplex) // C4127
        new (d->end()) T(std::move(copy));
      else
        *d->end() = std::move(copy);
      

      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
      2
      • M Offline
        M Offline
        Mwoua_Leddar
        wrote on last edited by
        #3

        Well, there is no standard way, but at least, with info from your link, I could add
        if ( MSVC )
        add_compile_options(/experimental:external /external:I C:/Qt/5.15.1/msvc2019_64 /external:W0)
        endif()

        So that I dont have warnings from Qt headers anymore.

        It created a lot (really a lot) of warning C4251, but they are usefull warning cause by a dll export of an entire class, which is bad design.

        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