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
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ StatementMacros:
- ITK_CLANG_PRAGMA_PUSH
- ITK_CLANG_PRAGMA_POP
- ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
- ITK_CLANG_SUPPRESS_Wduplicate_enum
- CLANG_PRAGMA_PUSH
- CLANG_PRAGMA_POP
- CLANG_SUPPRESS_Wfloat_equal
Expand Down
1 change: 1 addition & 0 deletions Examples/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ StatementMacros:
- ITK_CLANG_PRAGMA_PUSH
- ITK_CLANG_PRAGMA_POP
- ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
- ITK_CLANG_SUPPRESS_Wduplicate_enum
- CLANG_PRAGMA_PUSH
- CLANG_PRAGMA_POP
- CLANG_SUPPRESS_Wfloat_equal
Expand Down
3 changes: 3 additions & 0 deletions Modules/Core/Common/include/itkCommonEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class CommonEnums
* refers to the actual storage class associated with either a
* SCALAR pixel type or elements of a compound pixel.
*/
ITK_CLANG_PRAGMA_PUSH
ITK_CLANG_SUPPRESS_Wduplicate_enum
enum class IOComponent : uint8_t
{
UNKNOWNCOMPONENTTYPE,
Expand Down Expand Up @@ -99,6 +101,7 @@ class CommonEnums
FLOAT32 = FLOAT,
FLOAT64 = DOUBLE
};
ITK_CLANG_PRAGMA_POP

/**
* \ingroup ITKCommon
Expand Down
14 changes: 12 additions & 2 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,22 @@ namespace itk
#if defined(__clang__) && defined(__has_warning)
# define ITK_CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
# define ITK_CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \
ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant")
# if __has_warning("-Wzero-as-null-pointer-constant")
# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \
ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant")
# else
# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
# endif
# if __has_warning("-Wduplicate-enum")
# define ITK_CLANG_SUPPRESS_Wduplicate_enum ITK_PRAGMA(clang diagnostic ignored "-Wduplicate-enum")
# else
# define ITK_CLANG_SUPPRESS_Wduplicate_enum
# endif
Comment on lines +130 to +134
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the if __has_warning is necessary to avoid another warning (warning: unknown warning group '-W...', ignored [-Wunknown-warning-option]). Unfortunately it's a bit cumbersome to have 5 lines of boilerplate code to define such a macro (ITK_CLANG_SUPPRESS_Wduplicate_enum), for just one warning. Would it be possible to make macro definitions like this more concise? And would it be possible to just specify the string "-Wduplicate-enum" once, instead of twice? I'm just asking. 🤷 No show stopper.

#else
# define ITK_CLANG_PRAGMA_PUSH
# define ITK_CLANG_PRAGMA_POP
# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
# define ITK_CLANG_SUPPRESS_Wduplicate_enum
#endif

// These were not intended as public API, but some code was nevertheless using them.
Expand Down
Loading