From a5989825db5980e913e03021f26bdf154f269a9d Mon Sep 17 00:00:00 2001 From: Mark Asselin Date: Sat, 9 Apr 2022 21:51:40 -0400 Subject: [PATCH] COMP: Fix Slicer vtkITK build on macOS This commit addresses a Slicer macOS build error reported on Discourse (see https://discourse.slicer.org/t/slicer-build-on-macos-monterey/21940) and on GitHub (see comments on issue #5944). The _POSIX_SOURCE preprocessor identifier is defined in several places including by Python and several ITK ThirdParty modules. It looks like this definition is causing unintended side effects when building vtkITK. When itkMacro.h is #included in vtkITK, _POSIX_SOURCE causes conditional inclusion of code using __assert_fail and __ASSERT_FUNCTION, which are defined by GLIBC. Compiling under Clang on macOS this results in a compile error. This commit fixes the error by checking for the __GLIBC__ preprocessor identifier instead of __POSIX_SOURCE. --- Modules/Core/Common/include/itkMacro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/itkMacro.h b/Modules/Core/Common/include/itkMacro.h index 6f0d504879b..e19fcfaf701 100644 --- a/Modules/Core/Common/include/itkMacro.h +++ b/Modules/Core/Common/include/itkMacro.h @@ -776,7 +776,7 @@ compilers. #ifndef NDEBUG -# ifdef _POSIX_SOURCE +# ifdef __GLIBC__ # define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION); # else # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);