Compile error with std::bitset and Qt in VS2017
-
I am using Qt5.12.7 and VS2017. I have some legacy code that is using std::bitset and the compiler is throwing the same 'operator /' error reported in https://bugreports.qt.io/browse/QTBUG-72073
Currently I managed to bypass the problem by changing the bitset file in VS2017 as suggested in one of the comment at the above link:
Replace all "_Pos / _Bitsperword" with "_Pos / size_t(_Bitsperword)" in C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\bitsetIs there better way or official fix to solve this issue? I noticed it seems being reported and fixed in VS2019. The bug report above seems suggesting it has been fixed but I'm still running into the same problem in the latest LTS Qt version and latest VS2017.
-
The bugreport contains a fix - did you try it?
-
@Christian-Ehrlicher Do you mean QT_NO_FLOAT16_OPERATORS? How to use this fix?
-
@johnyang said in Compile error with std::bitset and Qt in VS2017:
How to use this fix?
Apply the patch to your Qt sources. If you don't compile from sources then you only have to apply the changes for qfloat16.h
-
@Christian-Ehrlicher said in Compile error with std::bitset and Qt in VS2017:
qfloat16.h
It looks like the latest 5.12.7 has the updated qflaot16.h with QT_NO_FLOAT16_OPERATORS lines. But how to use it? I need to define QT_NO_FLOAT16_OPERATORS somewhere in my source code or where the bitset is being used?
-
You don't need anything - simply use 5.12.7 and you're fine. If you still have some problems you for sure don't use 5.12.7 I would guess - you can simply see if you've the correct version by looking into qfloat16.h and see if the patch is in.