Skip to content

COMP: Fix missing direct include for macro definition - #7026

Closed
mymonin wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
mymonin:fix-macro-include
Closed

mymonin wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
mymonin:fix-macro-include

Conversation

@mymonin

@mymonin mymonin commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Closes #7025

This should fix ARMBUILD-Ubuntu-24.04-arm compilation failures which can be observed in other PRs like #7024 (cdash build error trace) and #7021 (cdash build error trace).

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

Refer to the ITK Software Guide for
further development details if necessary.

@github-actions github-actions Bot added type:Compiler Compiler support or related warnings type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module labels Oct 28, 2026
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds the direct itkMacro.h include needed by itkIndent.h.

  • ITK's print helpers can use Indent without a header loop.

Reviews (2) · Last reviewed commit: "COMP: Fix missing direct include for mac..." · Reviewed by Greptile

Comment thread Modules/Core/Common/include/itkIndent.h Resolved
@mymonin
mymonin marked this pull request as draft October 28, 2026 09:35
itk::Indent uses itkLegacyMacro so itkMacro.h should be included directly.

Also forward-declare itk::Indent in itkPrintHelper.h to avoid circular include
dependency problems.
@mymonin
mymonin marked this pull request as ready for review October 28, 2026 11:13

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on a glance. What commit introduced this build error?

@mymonin

mymonin commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Looks good on a glance. What commit introduced this build error?

Based on the git history of itkIndent.h, I assume it is 70ddeb8, which I referred to in the description of #7025 (closed by this PR).

@hjmjohnson hjmjohnson left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mymonin for tracking this down and for the clear repro in #7025. I'd like to take a different route, so I opened #7028, which keeps your diagnosis and your itkIndent.h-first regression include (credited as co-author).

Two concerns with the forward declarations here:

  1. The forward-declared operator<< lacks ITKCommon_EXPORT. The real declaration is friend ITKCommon_EXPORT std::ostream & operator<<(std::ostream &, const Indent &); (itkIndent.h). In a file that includes itkIndent.h first, the plain declaration is seen before the exported one, which MSVC shared builds can reject as inconsistent DLL linkage (C2375/C4273).
  2. Two declarations of the same signature to keep in sync. Item 1 is that drift already happening. I'd rather remove the cycle than paper over it.

#7028 restores @blowekamp's earlier fix (79f01ca, 4f524e8), where itkIndent.h does not include itkMacro.h, by including only ITKCommonExport.h and itkConfigure.h and marking the legacy New()/Delete() with [[deprecated]] instead of itkLegacyMacro. It also adds an #error in itkPrintHelper.h that names the fix if itkIndent.h ever pulls in itkMacro.h again.

@mymonin

mymonin commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

I agree #7028 is a better fix if we can afford moving the macro definition to a more suitable header. Avoiding any circular include dependency makes the header logic much easier to reason about.

@hjmjohnson

Copy link
Copy Markdown
Member

@mymonin 7028 was harder to complete than I expected. Can you please verify (on that PR) that the proposed solution works for you?

@hjmjohnson

Copy link
Copy Markdown
Member

Superceeded.

@hjmjohnson hjmjohnson closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Compiler Compiler support or related warnings type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COMP: itkMacro.h must be included before itkIndent.h

3 participants