[SOLVED] Qt5 + VS2010 QDateTime => not enough actual parameters for macro 'min' & 'max'
-
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?
-
#define NOMINMAX before including windows.h header. This is only way at the moment...
-
-
Hitting with 5.1.0 RC2 as well. I am using 32 bit MSVC2010 and the default variant (angel?).
-
Did you try switching to VS2012? I encountered the same problem
-
You should define NOMINMAX when including <windows.h>. Period. And WIN32_LEAN_AND_MEAN, by the way.
-
@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.
-
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.
-
Thanks for help Laszlo! Defining @DEFINES += NOMINMAX@ in pro file helped me.
-
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.
-
This thread helped me out with this issue. THANK YOU.
-
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? -
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