COMP: Suppress deprecated VariableLengthVector::AllocateElements warnings in MSVC wrapping builds#5863
Conversation
Add /wd4996 to MSVC compile flags for SWIG-generated Python wrapper targets. This suppresses C4996 warnings triggered by deprecated VariableLengthVector::AllocateElements calls in auto-generated wrapper code. GCC/Clang wrapping builds already suppress all warnings with -w.
N-Dekker
left a comment
There was a problem hiding this comment.
Thanks, but why is AllocateElements wrapped? I don't think it should be part of the Python interface. Here it is:
ITK/Modules/Core/Common/include/itkVariableLengthVector.hxx
Lines 198 to 210 in 093598d
So it basically just returns a raw pointer created by new TValue[size].
|
If it's only ITK/Modules/Core/Common/include/itkVariableLengthVector.h Lines 767 to 774 in 093598d Instead of explicitly using ITK/Modules/Core/Common/include/itkMacro.h Lines 1473 to 1477 in 093598d You see |
|
The wrapping should be compiled with ITK_LEGACY_SILENT enabled. But this function is not respecting that, there should be some macros to support this functionality of respecting deprecation to be silent. |
Then we should fix this function, right? |
|
That would make a fine follow up pull request, if you'd like. |
This member function is only marked `ITK_FUTURE_LEGACY_REMOVE`, so using this
member function should only trigger a warning when legacy support is removed,
and when `ITK_LEGACY_SILENT` is off.
Aims to fix warnings like:
itkVariableLengthVectorPython.cpp(5150): warning C4996: 'itk::VariableLengthVector::AllocateElements': Please consider calling `std::make_unique<TValue[]>(size)` instead.
At Windows_NT-Build4935-main-Python (https://open.cdash.org/builds/11095793)
As reported by Matt McCormick at InsightSoftwareConsortium#5863
This member function is only marked `ITK_FUTURE_LEGACY_REMOVE`, so using this
member function should only trigger a warning when legacy support is removed
_and_ `ITK_LEGACY_SILENT` is off.
Aims to fix warnings like:
itkVariableLengthVectorPython.cpp(5150): warning C4996: 'itk::VariableLengthVector::AllocateElements': Please consider calling `std::make_unique<TValue[]>(size)` instead.
At Windows_NT-Build4935-main-Python (https://open.cdash.org/builds/11095793)
As reported by Matt McCormick at pull request InsightSoftwareConsortium#5863
|
|
@N-Dekker 👍 thanks |
This member function is only marked `ITK_FUTURE_LEGACY_REMOVE`, so using this
member function should only trigger a warning when legacy support is removed
_and_ `ITK_LEGACY_SILENT` is off.
Aims to fix warnings like:
itkVariableLengthVectorPython.cpp(5150): warning C4996: 'itk::VariableLengthVector::AllocateElements': Please consider calling `std::make_unique<TValue[]>(size)` instead.
At Windows_NT-Build4935-main-Python (https://open.cdash.org/builds/11095793)
As reported by Matt McCormick at pull request #5863
Summary
/wd4996to MSVC compile flags for SWIG-generated Python wrapper targets to suppress C4996 (deprecated declaration) warningsBackground
After
VariableLengthVector::AllocateElementswas deprecated with[[deprecated("Please consider calling std::make_unique<TValue[]>(size) instead.")]], the SWIG-generated Python wrapper code (itkVariableLengthVectorPython.cpp) triggers MSVC warning C4996 for each wrapped template instantiation:This happens because SWIG auto-generates wrapper functions that directly call the now-deprecated
AllocateElementsmethod. The generated code cannot be modified to avoid these calls.Fix
Add
/wd4996alongside the existing/wd4244in the MSVC compile flags for wrapping targets inWrapping/macro_files/itk_end_wrap_module.cmake. This is consistent with GCC/Clang wrapping builds, which already suppress all warnings via the-wflag on the same targets. Deprecation warnings remain active for hand-written ITK C++ code; this only affects auto-generated SWIG wrapper compilation.