Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65414

qrandom.h breaks compilation of MSVC

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.10.1
    • 5.10.0
    • Core: Other
    • None
    • 656804b9645a83430dcd0929c49b4065d43d7990

    Description

      We use this tiny snippet to add a random number to our entroy pool. It works as expected but won't compile with MSVC 2015 (Update 3) and /W3 /WX compile flags.

       

      #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
      #include <QRandomGenerator>
      #endif
       
      
      #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
          entropy += QRandomGenerator::securelySeeded().generate();
      #endif
      

      Compile error from include:

      c:\[...]\include\qtcore\qrandom.h(163): error C2220: warning treated as error - no 'object' file generated
      c:\[...]\include\qtcore\qrandom.h(163): warning C4003: not enough actual parameters for macro 'min'
      c:\[...]\include\qtcore\qrandom.h(163): error C2059: syntax error: ')'
      c:\[...]\include\qtcore\qrandom.h(163): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
      c:\[...]\include\qtcore\qrandom.h(164): warning C4003: not enough actual parameters for macro 'max'
      c:\[...]\include\qtcore\qrandom.h(201): error C2143: syntax error: missing ')' before ';'
      c:\[...]\include\qtcore\qrandom.h(201): error C2059: syntax error: ')'
      c:\[...]\include\qtcore\qrandom.h(201): error C2238: unexpected token(s) preceding ';'
      c:\[...]\include\qtcore\qrandom.h(204): error C2504: 'QRandomGenerator': base class undefined
      c:\[...]\include\qtcore\qrandom.h(205): error C2460: 'QRandomGenerator::QRandomGenerator64::System': uses 'QRandomGenerator::QRandomGenerator64', which is being defined
      c:\[...]\include\qtcore\qrandom.h(203): note: see declaration of 'QRandomGenerator::QRandomGenerator64'
      c:\[...]\include\qtcore\qrandom.h(208): error C2873: 'generate': symbol cannot be used in a using-declaration
      c:\[...]\include\qtcore\qrandom.h(239): warning C4003: not enough actual parameters for macro 'min'
      c:\[...]\include\qtcore\qrandom.h(239): error C2059: syntax error: ')'
      c:\[...]\include\qtcore\qrandom.h(239): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
      c:\[...]\include\qtcore\qrandom.h(240): warning C4003: not enough actual parameters for macro 'max'
      c:\[...]\include\qtcore\qrandom.h(245): error C2143: syntax error: missing ')' before ';'
      c:\[...]\include\qtcore\qrandom.h(245): error C2059: syntax error: ')'
      c:\[...]\include\qtcore\qrandom.h(245): error C2238: unexpected token(s) preceding ';'
      C:\[...]\source\src\global\Randomizer.cpp(35): error C2059: syntax error: 'using namespace'
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            misery André Klitzing
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes