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. [SOLVED] Qt5 + VS2010 QDateTime => not enough actual parameters for macro 'min' & 'max'
QtWS25 Last Chance

[SOLVED] Qt5 + VS2010 QDateTime => not enough actual parameters for macro 'min' & 'max'

Scheduled Pinned Locked Moved General and Desktop
21 Posts 12 Posters 41.7k 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.
  • A Offline
    A Offline
    AcerExtensa
    wrote on 22 Nov 2012, 10:56 last edited by
    #1

    Hi,
    I'm playing with Qt5 and have successfully compiled it from GIT under Windows 7 + VS 2010. It works(in most cases), but when I include <QDateTime> header it breaks whole compilation with following errors:

    @
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(123): warning C4003: not enough actual parameters for macro 'min'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(124): warning C4003: not enough actual parameters for macro 'min'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(125): warning C4003: not enough actual parameters for macro 'max'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(123): error C2589: '(' : illegal token on right side of '::'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(123): error C2059: syntax error : '::'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(124): error C2589: '(' : illegal token on right side of '::'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(124): error C2059: syntax error : '::'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(125): error C2589: '(' : illegal token on right side of '::'
    1>c:\QT\QT5_X86_GIT\qtbase\include\QtCore/qdatetime.h(125): error C2059: syntax error : '::'
    @

    This lines in datetime.h header make VS go crasy:
    @
    static inline qint64 nullJd() { return std::numeric_limits<qint64>::min(); }
    static inline qint64 minJd() { return std::numeric_limits<qint64>::min() / 2; }
    static inline qint64 maxJd() { return (std::numeric_limits<qint64>::max()) / 2; }
    @

    It happens only if you include <windows.h> in your project. And can be eliminated by defining NOMINMAX before windows.h headers. But it feels somehow broken...

    Does anyone has this problem too?

    God is Real unless explicitly declared as Integer.

    1 Reply Last reply
    1
    • N Offline
      N Offline
      nadir
      wrote on 18 Dec 2012, 09:54 last edited by
      #2

      Same problem, Qt5 RC2 Visual Studio 2010

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AcerExtensa
        wrote on 18 Dec 2012, 10:05 last edited by
        #3

        #define NOMINMAX before including windows.h header. This is only way at the moment...

        God is Real unless explicitly declared as Integer.

        N 1 Reply Last reply 17 Jul 2015, 06:39
        1
        • A Offline
          A Offline
          andishock
          wrote on 29 Jan 2013, 08:19 last edited by
          #4

          Hello,

          on some projects I get the same warnings and errors, though there is no include of windows.h.
          What else can cause this problem and how can I avoid it.

          Thanks for suggestions.

          Edit: Setting a compiler switch "/DNOMINMAX" fixed the problem.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            iphenion
            wrote on 1 May 2013, 20:12 last edited by
            #5

            Yes, still the same problem here: Qt5.0.2 32bit MSVC2010

            1 Reply Last reply
            0
            • D Offline
              D Offline
              djszapi
              wrote on 25 Jun 2013, 17:04 last edited by
              #6

              Hitting with 5.1.0 RC2 as well. I am using 32 bit MSVC2010 and the default variant (angel?).

              http://download.qt-project.org/snapshots/qt/5.1/5.1.0-rc2/backups/2013-06-25-65/qt-windows-opensource-5.1.0-rc2-msvc2010-x86-offline-2013-06-25-65.exe

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MaximAlien
                wrote on 12 Jul 2013, 17:34 last edited by
                #7

                Did you try switching to VS2012? I encountered the same problem

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  Violet Giraffe
                  wrote on 12 Jul 2013, 17:41 last edited by
                  #8

                  You should define NOMINMAX when including <windows.h>. Period. And WIN32_LEAN_AND_MEAN, by the way.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    djszapi
                    wrote on 12 Jul 2013, 17:47 last edited by
                    #9

                    @MaximAlien: Nope, the customer was stuck to 2010.

                    @Violet Giraffe: yes, it was mentioned above what to do, so we are aware of that. However, it would be nice to fix centrally in the Qt Project if possible. If not, it would be nice to be aware of the limitation why it is not possible.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      MaximAlien
                      wrote on 12 Jul 2013, 17:52 last edited by
                      #10

                      Defining like that:
                      @#define NOMINMAX
                      #include <windows.h>@
                      doesn't help me. Can you help me guys?

                      I have compilation errors in:
                      @static inline qint64 nullJd() { return std::numeric_limits<qint64>::min(); @

                      I have 2 windows.h includes in other classes.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        djszapi
                        wrote on 12 Jul 2013, 17:55 last edited by
                        #11

                        MaximAlien: have you tried "/DNOMINMAX"?

                        or DEFINES += NOMINMAX with qmake?

                        1 Reply Last reply
                        1
                        • M Offline
                          M Offline
                          MaximAlien
                          wrote on 12 Jul 2013, 18:00 last edited by
                          #12

                          Thanks for help Laszlo! Defining @DEFINES += NOMINMAX@ in pro file helped me.

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            sdolard
                            wrote on 29 Jul 2013, 09:20 last edited by
                            #13

                            Use this include "#include <*qt_*windows.h>" instead of #include <windows.h>

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              djszapi
                              wrote on 29 Jul 2013, 09:36 last edited by
                              #14

                              @sdolard: that will not ultimately help.

                              Also, not sure what you mean by stars in there.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                sdolard
                                wrote on 29 Jul 2013, 09:41 last edited by
                                #15

                                @Laszlo Papp
                                Sure, but qt_windows.h already include a define for NOMINMAX, and other stuffs. So it's better to use it.

                                Chars between * should be bolded.

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  djszapi
                                  wrote on 29 Jul 2013, 09:47 last edited by
                                  #16

                                  sdolard: the problem is that, it does more than what you need, so not compact enough. :)

                                  More importantly, you need to find and maintain the right place for the include. If you do it in the build system, it always works.

                                  Also, even though qt_windows.h is installed publicly, you could include anytime. However, if you wanna be nice, you would use qt win ifdefs around just in case, but then it is getting uglier. :)

                                  But yes, provided those drawbacks are not real problems, that also works.

                                  1 Reply Last reply
                                  0
                                  • X Offline
                                    X Offline
                                    XGuy
                                    wrote on 14 Sept 2013, 04:48 last edited by
                                    #17

                                    [quote author="AcerExtensa" date="1355825116"]#define NOMINMAX before including windows.h header. This is only way at the moment...[/quote]

                                    Hi
                                    i had the same problem and got it working by following your suggestion.
                                    thx.

                                    1 Reply Last reply
                                    0
                                    • F Offline
                                      F Offline
                                      frankiefrank
                                      wrote on 30 Aug 2014, 14:12 last edited by
                                      #18

                                      This thread helped me out with this issue. THANK YOU.

                                      "Roads? Where we're going, we don't need roads."

                                      1 Reply Last reply
                                      0
                                      • D Offline
                                        D Offline
                                        DimitriJunker
                                        wrote on 10 Sept 2014, 11:12 last edited by
                                        #19

                                        Hi,

                                        I have the same problem, but without an include of windows.h. So I can not enter a define before it and including
                                        DEFINES += NOMINMAX
                                        in the pro-file did'nt worked either.
                                        Any more ideas?

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          DimitriJunker
                                          wrote on 11 Sept 2014, 22:58 last edited by
                                          #20

                                          Hi,

                                          since I started the project I had to reinstall windows and so qt creator. Originaly i used mingw. Now I also installed mingw, but somehow the installation was not compleat and qt creator used msvc instead. After swiching back to mingw I got rid of the error. So it's solved for me, but others might have the same problem.

                                          Dimitri

                                          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