Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Modules/Core/Common/include/itkIndent.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#ifndef itkIndent_h
#define itkIndent_h

// itkMacro.h includes itkPrintHelper.h, which includes this header: never include itkMacro.h here.
#include "ITKCommonExport.h"
#include "itkConfigure.h" // ITK_LEGACY_REMOVE

#include <iostream>

Expand All @@ -54,15 +56,18 @@ class ITKCommon_EXPORT Indent
using Self = Indent;

#ifndef ITK_LEGACY_REMOVE
// [[deprecated]] rather than itkLegacyMacro, which would require itkMacro.h.
/** Method for creation.
\deprecated Instead of calling `New()`, please simply create an indent by directly constructing the object. Indent is
default-constructible, so it can be allocated on the stack. */
itkLegacyMacro(static Self * New();)
[[deprecated]] static Self *
New();

/** Destroy this instance.
\deprecated Instead of calling `Delete()`, please use the C++ pattern RAII ("Resource Acquisition Is
Initialization"). */
itkLegacyMacro(void Delete())
[[deprecated]] void
Delete()
{
delete this;
}
Expand Down Expand Up @@ -94,4 +99,7 @@ class ITKCommon_EXPORT Indent
};
} // end namespace itk

// Tested by itkPrintHelper.h to detect the include cycle described above.
#define itkIndent_h_complete

#endif
3 changes: 3 additions & 0 deletions Modules/Core/Common/include/itkPrintHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include "itkMacro.h"
#include "itkIndent.h"
#ifndef itkIndent_h_complete
Comment thread
dzenanz marked this conversation as resolved.
Resolved
# error "itk::Indent incomplete: itkIndent.h must not include itkMacro.h (keep ITKCommonExport.h, itkConfigure.h)"
#endif

#include <array>
#include <iostream>
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Common/test/itkPrintHelperGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*=========================================================================*/

// itkIndent.h first on purpose: it must compile before itkMacro.h is seen (issue #7025).
#include "itkIndent.h"
#include "itkPrintHelper.h"
#include "itkOffset.h"
#include "gtest/gtest.h"
Expand Down
Loading