From 77ee02dceed631e1a7ed350935cb4b46aa217dd2 Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Wed, 3 Jun 2020 13:58:33 +0100 Subject: [PATCH] Fail to compile if CHAR_BIT != 8 --- c/tskit/core.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c/tskit/core.h b/c/tskit/core.h index 3d74499afa..0cc0cec33f 100644 --- a/c/tskit/core.h +++ b/c/tskit/core.h @@ -35,6 +35,7 @@ extern "C" { #endif #include +#include #ifdef __GNUC__ #define TSK_WARN_UNUSED __attribute__((warn_unused_result)) @@ -46,6 +47,11 @@ extern "C" { #define restrict #endif +/* We assume CHAR_BIT == 8 when loading strings from 8-bit byte arrays */ +#if CHAR_BIT != 8 +#error CHAR_BIT MUST EQUAL 8 +#endif + /* This sets up TSK_DBL_DECIMAL_DIG, which can then be used as a * precision specifier when writing out doubles, if you want sufficient * decimal digits to be written to guarantee a lossless round-trip