Skip to content

Commit 829fd1f

Browse files
authored
Merge pull request #667 from benjeffery/char_size
Fail to compile if CHAR_BIT != 8
2 parents 5da361b + 77ee02d commit 829fd1f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

c/tskit/core.h

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern "C" {
3535
#endif
3636

3737
#include <stdbool.h>
38+
#include <limits.h>
3839

3940
#ifdef __GNUC__
4041
#define TSK_WARN_UNUSED __attribute__((warn_unused_result))
@@ -46,6 +47,11 @@ extern "C" {
4647
#define restrict
4748
#endif
4849

50+
/* We assume CHAR_BIT == 8 when loading strings from 8-bit byte arrays */
51+
#if CHAR_BIT != 8
52+
#error CHAR_BIT MUST EQUAL 8
53+
#endif
54+
4955
/* This sets up TSK_DBL_DECIMAL_DIG, which can then be used as a
5056
* precision specifier when writing out doubles, if you want sufficient
5157
* decimal digits to be written to guarantee a lossless round-trip

0 commit comments

Comments
 (0)