Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

INTMAX_MAX undefined?



  • Windows 10
    QTCreator 4.7.1
    QT SDK 5.11.1
    VS 2017
    

    QtMenus includes QWidget
    which includes QObject
    which, on windows, includes <chrono>
    which chokes saying:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\ratio(73): error C2065: 'INTMAX_MAX': undeclared identifier
    


  • @VRonin made the correct suggestion, to define this:

    __STDC_LIMIT_MACROS
    

    The other problem was that i had defined "round()" as a macro somewhere else

    Thanks everyone!


  • Lifetime Qt Champion

    Hi,

    @davecotter said in INTMAX_MAX undefined?:

    INTMAX_MAX

    This MSDN thread might be of interest.

    Hope it helps



  • yes i saw that. in stdint.h, if you're in a C++ file, it auto-defines "__STDC_LIMIT_MACROS" (although i DID attempt to just manually define it, to no avail).
    in any case, the problem is, that this IS a C++ file, so stdint.h hits these lines:

    # ifdef __cplusplus
     this stuff happens
     there is NO DEFINITION for INTMAX_MAX
    #else
     this stuff DOES NOT HAPPEN
     #define INTMAX_MAX whatever it's supposed to be
    #endif
    


  • found a possible problem. stdint.h seems to be being included from here:

    C:\Users\davec\Developer\Qt\Tools\QtCreator\bin\clang\lib\clang\6.0.1\include
    

    while i'm TRYING to use the one i've defined here:

    Z:\CF\opencflite-476.17.2\dist\include
    

    I think they are conflicting? Why are "clang" headers being used on windows? i thought it would stick to the MSVC stuff?



  • when i remove the clang one, i still get the errors :(



  • i hacked around it by just defining it myself, but the further errors are like this:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\chrono(569): warning C4002: too many arguments for function-like macro invocation 'round'
    

    is this about the compiler? i've been stumped for days on this


  • Lifetime Qt Champion

    @davecotter said in INTMAX_MAX undefined?:

    round

    Are you calling this? If so can you show how?



  • the file "chrono" (which is part of MSVC) is calling it. below on the line that starts "_NODISCARD"

    template<class _To,
    	class _Rep,
    	class _Period,
    	class = enable_if_t<_Is_duration_v<_To>
    		&& !treat_as_floating_point_v<typename _To::rep>>>
    	_NODISCARD constexpr _To round(const duration<_Rep, _Period>& _Dur)
    	{	// convert duration to another duration, round to nearest, ties to even
    	const _To _Floored{chrono::floor<_To>(_Dur)};
    	const _To _Ceiled{_Floored + _To{1}};
    	const auto _Floor_adjustment = _Dur - _Floored;
    	const auto _Ceil_adjustment = _Ceiled - _Dur;
    	if (_Floor_adjustment < _Ceil_adjustment
    		|| (_Floor_adjustment == _Ceil_adjustment && _Is_even(_Floored.count())))
    		{
    		return (_Floored);
    		}
    
    	return (_Ceiled);
    	}
    


  • i will PAY someone $100 per hour to help me fix this (assuming it gets fixed, ie: $0 if it doesn't get fixed). minimum pay $100 even if it takes you 5 minutes to fix. assuming we'll get on the fone and do screen sharing.

    Job Posting on UpWork



  • [I'm not interested in a fee]
    Can you provide a minimum example to reproduce the problem?

    Did you try adding the __STDC_LIMIT_MACROS definition as suggested above?
    In Qt Creator you can add DEFINES += __STDC_LIMIT_MACROS to your pro file and re-run qmake



  • no, this is a monolithic application with a required dependency on CFLite (apple's CoreFoundation). it worked before upgrading Qt to the latest. best is to do a screen share so you can just poke directly at the project

    yes i did that with the define thing, to no avail. the latest stdint auto-defines that when including from a C++ file anyway.



  • @davecotter said in INTMAX_MAX undefined?:

    it worked before upgrading Qt to the latest

    From what version were you upgrading from? chrono was added in Qt 5.9

    What update version of MSVC 2017 are you using?



  • worked in 5.9.1 and in 5.10.0. now on 5.11.1 which fails



  • @VRonin said in INTMAX_MAX undefined?:

    What update version of MSVC 2017 are you using?

    Did you update MSVC as well when moving to Qt 5.11.1?

    Can you update to 5.11.2? (I don't think it will fix the issue but worth the try)


  • Lifetime Qt Champion

    In addition to what @VRonin wrote, can you also show the code that triggers that error ?
    Can you trigger it with a minimal application ?



  • can you also show the code that triggers that error ?

    scroll up to my previous reply which starts: <<the file "chrono">>

    Can you trigger it with a minimal application ?

    no, this is a monolithic application with a required dependency on CFLite


  • Lifetime Qt Champion

    It was not completely clear whether including std::chrono's was enough to trigger that or if you had some specific part of your code using it that would be.

    We understood that you have a monolithic application. The question is; can you start from one of Qt's default project and use std's chrono in there to check whether it's working at all. If it is, then add CFLite, etc.

    As for why Clang on Windows, Clang is used for the code model.



  • i've updated to the latest MSDEV 2017 (community) and the latest Qt SDK (5.11.2), doesn't help.

    QMenu.h ends up including chrono, so, yes, default Qt apps (that have menus) definitely work with chrono / ratio (the file <ratio> is where the problem is revealed). Adding CFLite is actually a lot of work. :( I realize it's a fair test to ask for, but i'm hoping to avoid taking the time to make that test? i'm trying more things first...



  • minimal project posted here

    note this assumes you have python 2.7 installed. you can get the installer here.

    after you download the zip file above, and expand, go here:
    .../CFTest/project/qt/CFTest/CFTest_win.pro
    open that

    configure as seen in the screen shots below. the full line for cftest run exec is this:

    %{sourceDir}..\build\win_64_%{CurrentBuild:Type}%{CurrentBuild:Name}.app\Contents\Windows%{CurrentBuild:Name}.exe
    

    0_1540578058507_cflite - build.png
    0_1540578069563_cftest - build.png
    0_1540578072109_cftest - run.png
    0_1540578074762_cftest - dependencies.png



  • Did you succeed with it so far?



  • @VRonin made the correct suggestion, to define this:

    __STDC_LIMIT_MACROS
    

    The other problem was that i had defined "round()" as a macro somewhere else

    Thanks everyone!


Log in to reply