From fb92bb63a4dade8b58c9c648320f8feb9ad2ea5d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 23 Jan 2024 21:17:20 +0000 Subject: [PATCH] [C#] Check int lengths at compile time ...cause I was using the wrong headers trying to do debug builds and it took much too long to debug. --- csharp_strings.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/csharp_strings.py b/csharp_strings.py index 17b0bf88..9dd23d1f 100644 --- a/csharp_strings.py +++ b/csharp_strings.py @@ -350,6 +350,18 @@ _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits"); +// Int types across Windows/Linux are different, so make sure we're using the right headers. +_Static_assert(sizeof(void*) == sizeof(uintptr_t), "stdints must be correct"); +_Static_assert(sizeof(void*) == sizeof(intptr_t), "stdints must be correct"); +_Static_assert(sizeof(uint64_t) == 8, "stdints must be correct"); +_Static_assert(sizeof(int64_t) == 8, "stdints must be correct"); +_Static_assert(sizeof(uint32_t) == 4, "stdints must be correct"); +_Static_assert(sizeof(int32_t) == 4, "stdints must be correct"); +_Static_assert(sizeof(uint16_t) == 2, "stdints must be correct"); +_Static_assert(sizeof(int16_t) == 2, "stdints must be correct"); +_Static_assert(sizeof(uint8_t) == 1, "stdints must be correct"); +_Static_assert(sizeof(int8_t) == 1, "stdints must be correct"); + #define DECL_ARR_TYPE(ty, name) \\ struct name##array { \\ uint64_t arr_len; /* uint32_t would suffice but we want to align uint64_ts as well */ \\ -- 2.30.2