Skip to content

Commit

Permalink
[Backport PR-3369] COMP: Fix Slicer vtkITK build on macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markasselin authored and lassoan committed May 11, 2022
1 parent a87ecfc commit 46a71c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 46a71c7

Please sign in to comment.