diff --git a/c/tests/testlib.h b/c/tests/testlib.h index b8f580f715..89f69c3b8a 100644 --- a/c/tests/testlib.h +++ b/c/tests/testlib.h @@ -31,6 +31,7 @@ #include #include +#define _TSK_WORKAROUND_FALSE_CLANG_WARNING #include /* Global variables used in the test suite */ diff --git a/c/tskit/core.h b/c/tskit/core.h index 3ffd2c87c9..256260eb04 100644 --- a/c/tskit/core.h +++ b/c/tskit/core.h @@ -39,9 +39,13 @@ extern "C" { #include #include -#if defined(__clang__) && !defined(__cplusplus) +#if defined(_TSK_WORKAROUND_FALSE_CLANG_WARNING) && defined(__clang__) /* Work around bug in clang >= 6.0, https://github.com/tskit-dev/tskit/issues/721 * (note: fixed in clang January 2019) + * This workaround does some nasty fiddling with builtins and is only intended to + * be used within the library. To turn it on, make sure + * _TSK_WORKAROUND_FALSE_CLANG_WARNING is defined before including any tskit + * headers. */ #if __has_builtin(__builtin_isnan) #undef isnan diff --git a/c/tskit/tables.c b/c/tskit/tables.c index dc49f738b6..375fedd43c 100644 --- a/c/tskit/tables.c +++ b/c/tskit/tables.c @@ -32,6 +32,7 @@ #include #include +#define _TSK_WORKAROUND_FALSE_CLANG_WARNING #include #define DEFAULT_SIZE_INCREMENT 1024