Skip to content

Commit

Permalink
Merge pull request #758 from jeromekelleher/make-clang-fix-local
Browse files Browse the repository at this point in the history
Move fix for clang bug to C file.
  • Loading branch information
mergify[bot] authored Aug 11, 2020
2 parents 955c900 + 5806861 commit 95fca38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions c/tests/testlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <stdlib.h>

#include <CUnit/Basic.h>
#define _TSK_WORKAROUND_FALSE_CLANG_WARNING
#include <tskit/trees.h>

/* Global variables used in the test suite */
Expand Down
6 changes: 5 additions & 1 deletion c/tskit/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ extern "C" {
#include <stdint.h>
#include <limits.h>

#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
Expand Down
1 change: 1 addition & 0 deletions c/tskit/tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <float.h>
#include <math.h>

#define _TSK_WORKAROUND_FALSE_CLANG_WARNING
#include <tskit/tables.h>

#define DEFAULT_SIZE_INCREMENT 1024
Expand Down

0 comments on commit 95fca38

Please sign in to comment.