QDeadLineTimer - error C2039: max is no member of std::numeric_limits



  • Hi,

    I try to compile my code, but I get the following errors in Visual Studio 2015:

    1>  ### Compiling Common Headers...
    1>c:\qt\5.8\msvc2015\include\qtcore\qdeadlinetimer.h(61): error C2039: "max": Is no member of "std::numeric_limits<__int64>"
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\limits(960): note: view declaration of "std::numeric_limits<__int64>"
    1>c:\qt\5.8\msvc2015\include\qtcore\qdeadlinetimer.h(61): error C3861: "max": Identifier not found.
    1>c:\qt\5.8\msvc2015\include\qtcore\qdeadlinetimer.h(69): error C2039: "max": Is no member of "std::numeric_limits<__int64>"
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\limits(960): note: view declaration of "std::numeric_limits<__int64>"
    1>c:\qt\5.8\msvc2015\include\qtcore\qdeadlinetimer.h(69): error C2065: "max": Identifier not declared
    

    As you may see in the path, I use Qt 5.8 and translated the error messages to english. Do you have any idea, how I can compile my code?

    Greetings
    betaros


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you share your .pro file ?



  • Hi,

    I didn't had a .pro file, but I generated one with Visual Studio. I cannot show you the whole file, but I hope my edited version might also help. I just removed the filenames from my project.

    Project.pro

    # ----------------------------------------------------
    # This file is generated by the Qt Visual Studio Tools.
    # ------------------------------------------------------
    
    TEMPLATE = app
    TARGET = PROJECT
    DESTDIR = ../../Debug
    CONFIG += debug console
    DEFINES += PROJECT_DEF
    INCLUDEPATH += ./../../PROJECT \
        ./GeneratedFiles \
        $(NOINHERIT)
    LIBS += -L"." \
        -lShlwapi \
        -lAdvapi32 \
        -lWs2_32
    PRECOMPILED_HEADER = "./utils/Includes.h"
    DEPENDPATH += .
    MOC_DIR += ./GeneratedFiles
    OBJECTS_DIR += debug
    UI_DIR += .
    RCC_DIR += ./%(RootDir)%(Directory)
    #Edited
    HEADERS += .. 
    #Edited
    SOURCES += ..
    #Edited
    FORMS += ..
    RESOURCES += ../Resources/Resources.qrc
    

    Greetings
    betaros


  • Lifetime Qt Champion

    Sorry, I almost never think of the use of the Visual Studio integration. Try adding /DNOMINMAX to your project defines.



  • @SGaist: No problem :) I have solved the problem by finding a point in the source code where the preprocessor overrides the max function...

    Now it finds the right max function. But thank you for your help :)


  • Lifetime Qt Champion

    It was in your sources ?



  • Yes. I got a big codebase and try to compile it. I got the error because in the defines was something written like:

    #define max(x,y) qMax(x,y)
    

    Removing that resolved the probem.


  • Lifetime Qt Champion

    Tricky one !

    Thanks for sharing :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.