Skip to content

COMP: Migrate deprecated itkTypeMacro/itkNewMacro for ITK 6 (release-5.4 compatible)#47

Open
hjmjohnson wants to merge 6 commits into
pyushkevich:masterfrom
hjmjohnson:fix/itk6-getnameofclass-migration
Open

COMP: Migrate deprecated itkTypeMacro/itkNewMacro for ITK 6 (release-5.4 compatible)#47
hjmjohnson wants to merge 6 commits into
pyushkevich:masterfrom
hjmjohnson:fix/itk6-getnameofclass-migration

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Jul 6, 2026

Copy link
Copy Markdown

Make c3d build against ITK 6 — including builds configured with ITK_FUTURE_LEGACY_REMOVE and with the VXL 2026-06-09 VNL — while remaining compatible with the ITK release-5.4 series.

Verified: full c3d source compiles and links against both ITK 6 (all executables produced) and ITK v5.4.6 (zero errors).

Root cause

Three independent ITK 6 breakages:

  1. Under ITK_FUTURE_LEGACY_REMOVE, itkTypeMacro/itkTypeMacroNoParent become static_assert(false, …) directing callers to itkOverrideGetNameOfClassMacro/itkVirtualGetNameOfClassMacro.
  2. ITK 6 defines ITK_NOOP_STATEMENT as static_assert(true, "") unconditionally, and every itk macro ends in it — so bare itkGetMacro/itkSetMacro/itkNewMacro/itkOverrideGetNameOfClassMacro invocations (no trailing ;) fail with expected ';' after 'static_assert'. (ITK 5.4 left this expansion empty, so the same code built there.)
  3. The VXL 2026-06-09 sync removed vnl/vnl_file_matrix.h and vnl/vnl_finite.h.
Changes (six commits)
  1. itkTypeMacro(X, Super)itkOverrideGetNameOfClassMacro(X)
  2. itkTypeMacroNoParent(X)itkVirtualGetNameOfClassMacro(X)
  3. Trailing ; on itkNewMacro invocations
  4. Replace vnl_file_matrix<double> with a small ASCII matrix reader (GeneralLinearModel); drop a stale include in VoxelwiseRegression
  5. Trailing ; on itkGetMacro/itkSetMacro/itkOverrideGetNameOfClassMacro invocations
  6. Drop stale vnl/vnl_finite.h include in WrapDimension

Replacement macros exist since ITK 5.4.0; added semicolons are empty declarations under 5.4; the ASCII reader depends only on vnl_matrix + <fstream>. All six changes build against both series.

Verification
  • ITK 6 (with MorphologicalContourInterpolation remote module): full source compiles (91/91), links c3d, c2d, c4d, c3d_affine_tool; c3d -version runs.
  • ITK v5.4.6: configure rc=0, build rc=0, zero errors.

…acro

ITK 6 built with ITK_FUTURE_LEGACY_REMOVE turns itkTypeMacro(thisClass,
superclass) into a static_assert(false, ...) that instructs callers to use
itkOverrideGetNameOfClassMacro(thisClass) instead. Migrate all call sites.
itkOverrideGetNameOfClassMacro has existed since ITK 5.4.0, so this remains
compatible with the release-5.4 series.
…fClassMacro

Under ITK_FUTURE_LEGACY_REMOVE, itkTypeMacroNoParent(thisClass) becomes a
static_assert(false, ...) directing callers to itkVirtualGetNameOfClassMacro.
Available since ITK 5.4.0, so release-5.4 compatibility is preserved.
ITK 6's itkNewMacro ends in ITK_MACROEND_NOOP_STATEMENT (a static_assert
enforcing a trailing semicolon), so bare itkNewMacro(Self) fails to parse.
Add the semicolons; harmless (empty declaration) under release-5.4.
@hjmjohnson hjmjohnson marked this pull request as ready for review July 6, 2026 00:08
@hjmjohnson

Copy link
Copy Markdown
Author

@pyushkevich Preparing for ITKv6 compatibility. These changes are all ITK 5.4 compatible as well.

The VXL 2026-06-09 sync removed vnl/vnl_file_matrix.h. GeneralLinearModel read
its design and contrast matrices via vnl_file_matrix<double>; replace that with
a small whitespace-delimited ASCII reader producing a vnl_matrix<double>, which
builds against both the release-5.4 VNL (header still present) and ITK 6 VNL
(header removed). VoxelwiseRegression only carried a stale include; drop it.
…cros

ITK 6 defines ITK_MACROEND_NOOP_STATEMENT as static_assert(true, ""), so every
itk data-access macro (itkGetMacro, itkSetMacro, itkOverrideGetNameOfClassMacro)
must be terminated with a semicolon; bare invocations fail with "expected ';'
after 'static_assert'". Add the semicolons; harmless (empty declaration) under
release-5.4 where the noop statement expands to nothing.
The VXL 2026-06-09 sync removed vnl/vnl_finite.h. WrapDimension only carried a
stale include of it (no vnl_finite_int usage), so remove the include. Builds
against both release-5.4 and ITK 6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant