Skip to content

Commit 95fca38

Browse files
authored
Merge pull request #758 from jeromekelleher/make-clang-fix-local
Move fix for clang bug to C file.
2 parents 955c900 + 5806861 commit 95fca38

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

c/tests/testlib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <stdlib.h>
3232

3333
#include <CUnit/Basic.h>
34+
#define _TSK_WORKAROUND_FALSE_CLANG_WARNING
3435
#include <tskit/trees.h>
3536

3637
/* Global variables used in the test suite */

c/tskit/core.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ extern "C" {
3939
#include <stdint.h>
4040
#include <limits.h>
4141

42-
#if defined(__clang__) && !defined(__cplusplus)
42+
#if defined(_TSK_WORKAROUND_FALSE_CLANG_WARNING) && defined(__clang__)
4343
/* Work around bug in clang >= 6.0, https://github.com/tskit-dev/tskit/issues/721
4444
* (note: fixed in clang January 2019)
45+
* This workaround does some nasty fiddling with builtins and is only intended to
46+
* be used within the library. To turn it on, make sure
47+
* _TSK_WORKAROUND_FALSE_CLANG_WARNING is defined before including any tskit
48+
* headers.
4549
*/
4650
#if __has_builtin(__builtin_isnan)
4751
#undef isnan

c/tskit/tables.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <float.h>
3333
#include <math.h>
3434

35+
#define _TSK_WORKAROUND_FALSE_CLANG_WARNING
3536
#include <tskit/tables.h>
3637

3738
#define DEFAULT_SIZE_INCREMENT 1024

0 commit comments

Comments
 (0)