COMP: Fix PrintNumericTrait build error in debug mode#6278
Closed
blowekamp wants to merge 1 commit into
Closed
Conversation
itkIndent.h includes itkMacro.h, which in debug builds (inside #ifndef NDEBUG) re-included itkPrintHelper.h before class Indent was fully declared. PrintNumericTrait's `os << indent` then failed to resolve operator<<(ostream, const Indent &). Move the include to the bottom of itkIndent.h so itkPrintHelper.h always sees the complete class and its operator<<. Remove the now- redundant forward declaration of class Indent from itkPrintHelper.h.
dzenanz
reviewed
May 14, 2026
| }; | ||
| } // end namespace itk | ||
|
|
||
| #ifndef NDEBUG |
Member
There was a problem hiding this comment.
Do we need this debug guard? Don't we want print helpers to be available to release builds too?
Member
Author
There was a problem hiding this comment.
I am not able to follow the logic of what was originally done despite the length of the comments.
The "using namespace ::itk::print_helper;" was only in the itkDebugMacro, so it's not widely used in ITK. I am skeptical if the addition of the print_helper change was well thought out.
Member
Author
|
Replaced by: #6280 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move
itkPrintHelper.hinclude fromitkMacro.hto the bottom ofitkIndent.h, fixing a build error in debug mode.Root cause
itkIndent.hincludesitkMacro.h, which inside#ifndef NDEBUGre-includeditkPrintHelper.hbeforeclass Indentwas fully declared.PrintNumericTrait'sos << indentthen failed to resolveoperator<<(ostream, const Indent &):Moving the include to the bottom of
itkIndent.hensuresitkPrintHelper.halways sees the complete class and itsoperator<<. The now-redundantclass Indent;forward declaration initkPrintHelper.his also removed.AI assistance
GitHub Copilot (Claude Sonnet 4.6) identified the circular include chain and proposed this fix. Verified locally by building
ITKCommonwith thedebugCMake preset (GCC 13,-DCMAKE_BUILD_TYPE=Debug).