mp-units
mp-units copied to clipboard
Fail to compile v2.0.0 with MSVC
Hi
I'm trying to compile mp-units 2.0.0 on windows with Visual Studio (tried with 16 and 17), but it fails. It was working well with v0.8.0
I'm using cmake directly (i'm building a conda package of mp-units btw), and got a lot of compilers errors:
Building Custom Rule H:/Mambaforge/conda-bld/mp-units_1699864922028/work/example/CMakeLists.txt
ClCompile:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\CL.exe /c /I"%SRC_DIR%\src\core-io\include" /I"%SRC_DIR%\src\core\include" /I"%SRC_DIR%\src\systems\si\include" /I"%SRC_DIR%\src\systems
\isq\include" /I"%SRC_DIR%\src\systems\cgs\include" /I"%SRC_DIR%\src\systems\usc\include" /I"%SRC_DIR%\src\systems\international\include" /nologo /W4 /WX- /diagnostics:column /O2 /Ob2 /D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_IN
TDIR=\"Release\"" /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++20 /permissive- /Fo"avg_speed.dir\Release\\" /Fd"avg_speed.dir\Release\vc143.pdb" /external:W0 /Gd /TP /errorReport:queue /we4289 /externa
l:I "H:/Mambaforge/conda-bld/mp-units_1699864922028/_h_env/Library/include" /w14062 /w14242 /w14254 /w14263 /w14265 /w14266 /w14287 /w14296 /w14311 /w14545 /w14546 /w14547 /w14549 /w14555 /w14619 /w14640 /w14826 /w14905 /w14906 /w14928
/utf-8 "%SRC_DIR%\example\avg_speed.cpp"
avg_speed.cpp
%SRC_DIR%\src\core\include\mp-units/unit.h(410,31): error C7601: the associated constraints are not satisfied [%SRC_DIR%\build\example\avg_speed.vcxproj]
%SRC_DIR%\src\core\include\mp-units/unit.h(405,34): message : the concept 'mp_units::Unit<mp_units::scaled_unit<M{},mp_units::one>>' evaluated to false [%SRC_DIR%\build\example\avg_speed.vcxproj]
with
[
M=mp_units::magnitude<mp_units::power_v<2,-2>{},mp_units::power_v<5,-2>{}>
]
%SRC_DIR%\src\core\include\mp-units/bits/unit_concepts.h(46,16): message : the constraint was not satisfied [%SRC_DIR%\build\example\avg_speed.vcxproj]
%SRC_DIR%\src\core\include\mp-units/unit.h(587,70): message : see reference to function template instantiation 'auto mp_units::operator *<_T0,mp_units::one>(M,const U)' being compiled [%SRC_DIR%\build\example\avg_speed.vcxproj]
with
[
_T0=mp_units::magnitude<mp_units::power_v<2,-2>{},mp_units::power_v<5,-2>{}>,
M=mp_units::magnitude<mp_units::power_v<2,-2>{},mp_units::power_v<5,-2>{}>,
U=mp_units::one
]
%SRC_DIR%\src\core\include\mp-units/unit.h(587,35): error C2504: 'mp_units::named_unit<mp_units::basic_symbol_text<char,1,1>{mp_units::basic_fixed_string<char,1>{CharT37,0},mp_units::basic_fixed_string<CharT,1>{CharT37,0}},mp_units::sca
led_unit<M{},mp_units::one>{}>': base class undefined [%SRC_DIR%\build\example\avg_speed.vcxproj]
with
[
CharT=char,
M=mp_units::magnitude<mp_units::power_v<2,-2>{},mp_units::power_v<5,-2>{}>
]
%SRC_DIR%\src\core\include\mp-units/unit.h(588,37): error C2504: 'mp_units::named_unit<mp_units::basic_symbol_text<char,3,2>{mp_units::basic_fixed_string<char,3>{CharT226,128,176,0},mp_units::basic_fixed_string<CharT,2>{CharT37,111,0}},
mp_units::scaled_unit<M{},mp_units::one>{}>': base class undefined [%SRC_DIR%\build\example\avg_speed.vcxproj]
with
[
CharT=char,
M=mp_units::magnitude<mp_units::power_v<2,-3>{},mp_units::power_v<5,-3>{}>
]
%SRC_DIR%\src\core\include\mp-units/reference.h(76,73): error C2059: syntax error: '<end Parse>' [%SRC_DIR%\build\example\avg_speed.vcxproj]
%SRC_DIR%\src\core\include\mp-units/reference.h(156,2): message : see reference to class template instantiation 'mp_units::reference<Q,U>' being compiled [%SRC_DIR%\build\example\avg_speed.vcxproj]
%SRC_DIR%\src\core\include\mp-units/reference.h(76,79): error C2143: syntax error: missing ';' before '{' [%SRC_DIR%\build\example\avg_speed.vcxproj]
%SRC_DIR%\src\core\include\mp-units/reference.h(76,73): error C2143: syntax error: missing '>' before ';' [%SRC_DIR%\build\example\avg_speed.vcxproj]
...
[SKIP a lot of errors]
...
%SRC_DIR%\src\systems\angular\include\mp-units/systems/angular/angular.h(51,23): error C2737: 'mp_units::angular::unit_symbols::deg2': constexpr object must be initialized [%SRC_DIR%\build\example\unmanned_aerial_vehicle.vcxproj]
%SRC_DIR%\src\core\include\mp-units/quantity_spec.h(1344,27): error C2131: expression did not evaluate to a constant [%SRC_DIR%\build\example\unmanned_aerial_vehicle.vcxproj]
%SRC_DIR%\src\core\include\mp-units/quantity_spec.h(355,90): fatal error C1903: unable to recover from previous error(s); stopping compilation [%SRC_DIR%\build\example\unmanned_aerial_vehicle.vcxproj]
0 Warning(s)
3153 Error(s)
Do you plan to support Visual studio again ? Or did i miss something ? Thanks.
Do you plan to support Visual studio again ? Or did i miss something ? Thanks.
Yeah. This was mentioned in the latest talk: https://github.com/mpusz/mp-units/discussions/451#discussioncomment-7316987.
@nniclausse, you can find the list of supported compilers at https://mpusz.github.io/mp-units/2.1/getting_started/installation_and_usage/. Unfortunately, MSVC is the worst one with C++20 support now. We submitted many bugs to MSVC teams, and we are waiting for them to be resolved so we may continue our efforts to make the project compile on it.
ok, thanks for your feedback, i'll try clang on windows
Hi, is MSVC still out of the list? (a list of supported compilers in the GitHub page would help).
Yes, MSVC still does not properly support C++20.
The list of supported compilers is provided on the main page of our docs (https://mpusz.github.io/mp-units/2.2).
Yes, MSVC still does not properly support C++20.
The list of supported compilers is provided on the main page of our docs (https://mpusz.github.io/mp-units/2.2).
Thanks a lot. It seems to me there is no way to bypass the problem, I have significant issues with the concepts that are not properly evaluated...
Is there a list with corresponding bugs you submitted? Having this list would enable me to track them and give them a vote.
Unfortunately, there is no list, and I did not submit the bugs. Also, many bugs are still not submitted as no one had time to investigate and isolate them. Diagnostics (error messages) suck in MSVC, so it is not easy to find the root cause of the problem.
However, one of the MSVC developers promised that they would try to enable mp-units internally for their CI. Hopefully, this will push things forward.
My team is also blocked by this; using Unreal Engine 5.4 locks us into MSVC for Windows.
Here's the relevant part of my error log:
mp-units\framework\reference.h(90): error C2275: 'Q': expected an expression instead of a type
mp-units/framework/reference.h(90): note: the template instantiation context (the oldest one first) is
mp-units/framework/reference.h(76): note: while compiling class template 'mp_units::reference'
... then a lot of syntax errors from the {} not
Referenced line: https://github.com/mpusz/mp-units/blob/ab51b47328c2dadace2ab934dbaedc4e275a4cda/src/core/include/mp-units/framework/reference.h#L89-L93
- Visual C++ 19.40 (MSVC v143) (Visual Studio 2022 17.10)
- x64
- Windows 11