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. Build errors in qjsnumbercoercion.h under Qt 6.6.0 on Windows 11
QtWS25 Last Chance

Build errors in qjsnumbercoercion.h under Qt 6.6.0 on Windows 11

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 403 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.
  • E Offline
    E Offline
    Escovado
    wrote on last edited by
    #1

    Hello. I've been in Qt development for a little over two years. This is my first post here.

    Our C++ project on Windows 11 builds correctly under Qt 5.15.2 and 6.5.2. I installed Qt 6.6.0 and tried to build. I am getting compiler errors in the Qt header file C:\Qt\6.6.0\msvc2019_64\include\QtQml\qjsnumbercoercion.h. The compiler error appears to be triggered by the file's use of std::numeric_limit, in the function isInteger. This function has been changed in the qjsnumbercoercion.h header file between versions Qt 6.5.2 and 6.6.0.

    Here's the 6.5.2 version that builds:

    static constexpr bool isInteger(double d) {
            return equals(d, d) && equals(static_cast<int>(d), d);
        }
    

    And here's the 6.6.0 version that does not build:

    static constexpr bool isInteger(double d)
        {
            // Comparing d with itself checks for NaN and comparing d with the min and max values
            // for int also covers infinities.
            if (!equals(d, d) || d < std::numeric_limits<int>::min()
                || d > std::numeric_limits<int>::max()) {
                return false;
            }
    
            return equals(static_cast<int>(d), d);
        }
    

    I've added a screenshot from Qt Creator to show the compiler error messages here:

    Qt_6_6_0_Build_Error.png

    Do I have to change something in the configuration? Thanks.

    Chris KawaC 1 Reply Last reply
    0
    • E Escovado

      Hello. I've been in Qt development for a little over two years. This is my first post here.

      Our C++ project on Windows 11 builds correctly under Qt 5.15.2 and 6.5.2. I installed Qt 6.6.0 and tried to build. I am getting compiler errors in the Qt header file C:\Qt\6.6.0\msvc2019_64\include\QtQml\qjsnumbercoercion.h. The compiler error appears to be triggered by the file's use of std::numeric_limit, in the function isInteger. This function has been changed in the qjsnumbercoercion.h header file between versions Qt 6.5.2 and 6.6.0.

      Here's the 6.5.2 version that builds:

      static constexpr bool isInteger(double d) {
              return equals(d, d) && equals(static_cast<int>(d), d);
          }
      

      And here's the 6.6.0 version that does not build:

      static constexpr bool isInteger(double d)
          {
              // Comparing d with itself checks for NaN and comparing d with the min and max values
              // for int also covers infinities.
              if (!equals(d, d) || d < std::numeric_limits<int>::min()
                  || d > std::numeric_limits<int>::max()) {
                  return false;
              }
      
              return equals(static_cast<int>(d), d);
          }
      

      I've added a screenshot from Qt Creator to show the compiler error messages here:

      Qt_6_6_0_Build_Error.png

      Do I have to change something in the configuration? Thanks.

      Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      @Escovado It's not a problem with Qt. This error means that your global namespace is polluted with a min macro and the compiler tries to expand that macro when it sees "min" in std::numeric_limits<int>::min(), which is not a macro.

      Number of libraries do that sadly, the most notorious one on Windows are the windows headers themselves. If you have windows.h or other WinAPI headers in your project try to add #define NOMINMAX before you include them or add that globally to your project. This prevents windows headers from defining these macros. You can add #define WIN32_LEAN_AND_MEAN while you're at it, which further decreases global scope pollution that windows headers do and shortens compilation times too.

      If the macro doesn't come from windows headers you'll have to track it down otherwise, but the problem is the global macro, not the code in Qt.

      E 1 Reply Last reply
      1
      • Chris KawaC Chris Kawa

        @Escovado It's not a problem with Qt. This error means that your global namespace is polluted with a min macro and the compiler tries to expand that macro when it sees "min" in std::numeric_limits<int>::min(), which is not a macro.

        Number of libraries do that sadly, the most notorious one on Windows are the windows headers themselves. If you have windows.h or other WinAPI headers in your project try to add #define NOMINMAX before you include them or add that globally to your project. This prevents windows headers from defining these macros. You can add #define WIN32_LEAN_AND_MEAN while you're at it, which further decreases global scope pollution that windows headers do and shortens compilation times too.

        If the macro doesn't come from windows headers you'll have to track it down otherwise, but the problem is the global macro, not the code in Qt.

        E Offline
        E Offline
        Escovado
        wrote on last edited by Escovado
        #3

        Adding the #define NOMINMAX in the source file that loads a lot of header files did the trick. I'll have to track down the specific header that's causing this. You put me on the right track. Thank you.

        1 Reply Last reply
        0
        • E Escovado has marked this topic as solved on

        • Login

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