Repository navigation
COMP: Restore itkIndent.h without itkMacro.h and fail loudly on the include cycle - #7028
Conversation
9680e1d to
374e7f9
Compare
[Medium impact] This PR appears safe to merge.
|
itkMacro.h includes itkPrintHelper.h, which includes itkIndent.h, so itkIndent.h must not depend on itkMacro.h. Since 70ddeb8 it used itkLegacyMacro and ITK_LEGACY_REMOVE without including the headers that define them, so a file including itkIndent.h first failed to compile. Restore the earlier fix (79f01ca, 4f524e8): itkIndent.h includes only the leaf headers ITKCommonExport.h and itkConfigure.h, and marks the legacy New() and Delete() with [[deprecated]] instead of itkLegacyMacro. itkPrintHelper.h now stops with an #error naming the fix if itk::Indent is incomplete when it is reached, which is what including itkMacro.h from itkIndent.h again would cause. itkPrintHelperGTest.cxx includes itkIndent.h first so every build checks that order. Closes InsightSoftwareConsortium#7025. Co-Authored-By: Maxime Monin <318167326+mymonin@users.noreply.github.com>
|
Sorry for the noise here. 3 failed attempts accidently go co-mingled and pushed and did not represent what I have on my local build. I assumed my local build was the same as the PR incorrectly. |
374e7f9 to
3b548bd
Compare
|
I don't think adding another header into this complicate dependency order is the correct solution. The additional header will add more complication when similar issues are encountered. My recommendation is to keep the legacy macro where it is, but change itkIndent to directly use [deprecated note] with a comment why the macro is not used. ... this may have just happened with the latest push? |
|
@blowekamp I had already done that. That was the mistake I made in commingling solutions. You must have reviewed just before the fix. Sorry. |
|
Calling |
|
ITK.Linux.Python on |
|
/azp run ITK.Linux.Python |
|
Downstream regression check: no regressions attributable to this PR in the ITK forest testbed (upstream Consumer matrix
The sub-100% pass counts match earlier sweeps against plain Harness caveats (not caused by this PR)
|
f83647e
into
InsightSoftwareConsortium:main
Fixes #7025:
itkIndent.hfails to compile when it is included beforeitkMacro.h. This restores @blowekamp's May fix (commits79f01ca,4f524e8:itkIndent.hincludes noitkMacro.h, soitkMacro.h→itkPrintHelper.h→itkIndent.hcannot loop) and adds a loud error so the cycle cannot come back silently. Supersedes #7026 by @mymonin, whose issue, diagnosis, and include-first regression check this keeps.itkIndent.hincludes only the leaf headersITKCommonExport.handitkConfigure.h, and marks the legacyNew()/Delete()with[[deprecated]]instead ofitkLegacyMacro(which lives initkMacro.h), with a comment saying why.itkPrintHelper.hstops with a message naming the fix ifitk::Indentis incomplete when it is reached, which is what includingitkMacro.hfromitkIndent.hagain would cause.itkPrintHelperGTest.cxxincludesitkIndent.hfirst so every build exercises the order from COMP: itkMacro.h must be included before itkIndent.h #7025.One commit, three files, +15/−2. No forward declarations are needed, so nothing duplicates
Indent'soperator<<signature.How the cycle came back
79f01ca/4f524e8(May 2026) removed#include "itkMacro.h"fromitkIndent.h; an#ifndef itkMacro_h #errorwas tried first and dropped because it broke standalone inclusion inITKCommonHeaderTest1.70ddeb8(Sep 2026) wrappedIndent::New()/Delete()initkLegacyMacrounder#ifndef ITK_LEGACY_REMOVE. Both come fromitkMacro.h/itkConfigure.h, soitkIndent.hdepended onitkMacro.hagain without including it. Most files includeitkMacro.hfirst, so only the ARMBUILD header-test chunk that happened to listitkIndent.hfirst failed (ENH: Eliminateconst_castfromitk::ImageIterator#7021, ENH: Name the series in the non-uniform sampling warning of ImageSeriesReader #7024).[[deprecated]]differs fromitkLegacyMacroonly in thatITK_LEGACY_SILENT/ITK_LEGACY_TESTno longer silence it for these two members; nothing in ITK calls them, and both are removed underITK_LEGACY_REMOVE.itkMacro.hfromitkIndent.h(COMP: Fix missing direct include for macro definition #7026) re-creates the cycle and needs forward declarations ofIndentand itsoperator<<initkPrintHelper.h. That copy omitsITKCommon_EXPORT, and keeping two declarations in sync is the maintenance cost this PR avoids.Testing
macOS arm64, Apple clang, Debug,
ITKCommon+ITKImageIntensitywithMAXIMUM_NUMBER_OF_HEADERS=1(every header compiled on its own, includingitkIndent.halone):ctest: 1013/1013 passed.ITK_LEGACY_REMOVEdefined:itkIndent.halone anditkIndent.cxxcompile.#includein ITKCommon, include guards ignored):itkIndent.hincludes no other ITKCommon header (only the generated, include-freeITKCommonExport.handitkConfigure.h), so no cycle passes through it. The same check on COMP: Fix missing direct include for macro definition #7026 findsitkIndent.h → itkMacro.h → itkPrintHelper.h → itkIndent.h.#include "itkMacro.h"back toitkIndent.hmakesitkPrintHelperGTest.cxxstop withitkPrintHelper.h:25: error: "itk::Indent incomplete: itkIndent.h must not include itkMacro.h (keep ITKCommonExport.h, itkConfigure.h)".pre-commit run --all-filespasses.Not tested locally: Windows, Linux, Python wrapping.
AI assistance
Claude Code traced the history, wrote the change and the compile checks, and drafted this text at @hjmjohnson's direction; the build and tests above were run locally.