ITK
ITK copied to clipboard
[MSVC][C++23] ITK's copy of KWSys is returning 0 as std::string
Hi all,
This is the more errors from https://github.com/InsightSoftwareConsortium/ITK/issues/2637. Notice "Modules/ThirdParty/KWSys/src/KWSys/SystemTools.cxx" has been fixed, but the one under build dir still failed, not sure if they are the same file. Using latest code 8aed68490b733ba45b36b2e8e84e99980db45948.
error C2666 should be another issue.
Build steps:
- open VS2019 x86 tools command
- git clone https://github.com/InsightSoftwareConsortium/ITK F:\gitP\InsightSoftwareConsortium\ITK
- mkdir build_x86 && build_x86
- cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DBUILD_EXAMPLES=OFF ..
- set CL=/D_HAS_AUTO_PTR_ETC=1 /D_HAS_TR1_NAMESPACE=1 /D_HAS_DEPRECATED_RESULT_OF=1 /D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING /D_HAS_DEPRECATED_UNCAUGHT_EXCEPTION=1 /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING /std:c++latest /Zc:twoPhase- /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
- msbuild /m /p:Platform=Win32 /p:Configuration=Release All_BUILD.vcxproj /t:Rebuild
Build.log: build (3).log
F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\c++\src\H5PropList.cpp(558,1): error C2440: 'return': cannot convert from 'int' to 'std::basic_string<char,std::char_traits
F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle\Utilities\KWSys\SystemTools.cxx(4238,1): error C2440: 'return': cannot convert from 'int' to 'std::basic_string<char,std::char_traits
F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\GoogleTest\src\itkgoogletest\googletest\include\gtest/gtest.h(1527,1): error C2666: 'itk::FixedArray<double,2>::operator ==': 2 overloads have similar conversions [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\Modules\Core\Transform\test\ITKTransformGTestDriver.vcxproj] F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\GoogleTest\src\itkgoogletest\googletest\include\gtest/gtest.h(1527,1): error C2666: 'itk::FixedArray<T,3>::operator ==': 2 overloads have similar conversions [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\Modules\Core\Transform\test\ITKTransformGTestDriver.vcxproj]
KWStyle, a style checker tool ITK uses, has its own copy of KWSys. I will update it and I guess that will fix 3 instances.
The other errors are related to third party libraries we don't control (HDF5 and GTest). We can look into GTest one, as it seems to arise from our invocation. For HDF5, the solution will probably be to just update to newer version which has the fix.
Thanks @dzenanz! Verified the 3 instances have been fixed. For HDF5, I can patch it first.
Following the repro steps, I run into cl : command line error D8016: '/std:c++latest' and '/std:c11' command-line options are incompatible [C:\Misc\ITK-patches2-23\Modules\ThirdParty\VNL\src\vxl\v3p\netlib\itkv3p_netlib.vcxproj].
Yes, I also encountered this issue before, but this issue is still in MSVC‘s SuggestionTicket, so I just patch it locally under /std:c++latest mode to unblock test.
itk_c11_error_OSSOptionCppLatest.patch.txt
2 related feedbacks: https://developercommunity.visualstudio.com/t/vs2019-169-preview-3-cl-command-line-error-d8016-s/1343268 https://developercommunity2.visualstudio.com/t/C-and-C-standard-options-should-not-be/1289751
Did PR #2564 help with GTest errors?
Thanks for the fix, but verified this issue still exists. I provide you with a pre-compiled file with corresponding error lines in it. Hope that helps.
@N-Dekker I think the problem is that we are comparing a FixedArray to a Point returned by GetCenter(): https://github.com/InsightSoftwareConsortium/ITK/blob/230d319fdeaa3877273fab5d409dd6c11f0a6874/Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx#L39
and the compiler is confused about which class' equality operator to use. Should we solve this by a static_cast or something else?
static_cast<itk::FixedArray<double, NDimensions>>(transformBase->GetCenter()) does resolve the compile errors.
@QuellaZhang #2684 should be the last piece of the puzzle for this issue. Can you confirm and close?
Updated HDF5 (#2683) does not have the fix, so #2684 was needed.
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.
@QuellaZhang can you re-check that we resolved this?
Closing the issue, presumably fixed.