From 80fe96a04e88741d44c002c0e01be6c899ba8418 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 15 May 2020 17:49:32 +0200 Subject: [PATCH 1/3] librustzcash: make the header C compatible --- src/rust/include/librustzcash.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rust/include/librustzcash.h b/src/rust/include/librustzcash.h index 239093dc3..dab098473 100644 --- a/src/rust/include/librustzcash.h +++ b/src/rust/include/librustzcash.h @@ -3,6 +3,11 @@ #include +#ifndef __cplusplus + #define static_assert _Static_assert + #include +#endif + const int ENTRY_SERIALIZED_LENGTH = 180; typedef struct HistoryEntry { unsigned char bytes[ENTRY_SERIALIZED_LENGTH]; @@ -12,7 +17,9 @@ static_assert( "HistoryEntry struct is not the same size as the underlying byte array"); static_assert(alignof(HistoryEntry) == 1, "HistoryEntry struct alignment is not 1"); +#ifdef __cplusplus extern "C" { +#endif #ifdef WIN32 typedef uint16_t codeunit; #else @@ -343,6 +350,8 @@ extern "C" { const unsigned char *n_ptr, unsigned char *h_ret ); +#ifdef __cplusplus } +#endif #endif // LIBRUSTZCASH_INCLUDE_H_ From e465731e69e3d822d07ece958e2d4c2322e7bd4c Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 15 May 2020 19:46:45 +0200 Subject: [PATCH 2/3] Use assert.h instead of define manually static_assert --- src/rust/include/librustzcash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/include/librustzcash.h b/src/rust/include/librustzcash.h index dab098473..70f39539a 100644 --- a/src/rust/include/librustzcash.h +++ b/src/rust/include/librustzcash.h @@ -4,7 +4,7 @@ #include #ifndef __cplusplus - #define static_assert _Static_assert + #include #include #endif From 332ce1a8002a05651c350ba298036d601c14fa8e Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 15 May 2020 19:50:46 +0200 Subject: [PATCH 3/3] Use preprocessor for ENTRY_SERIALIZED_LENGTH --- src/rust/include/librustzcash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rust/include/librustzcash.h b/src/rust/include/librustzcash.h index 70f39539a..f69ae6c6d 100644 --- a/src/rust/include/librustzcash.h +++ b/src/rust/include/librustzcash.h @@ -8,7 +8,8 @@ #include #endif -const int ENTRY_SERIALIZED_LENGTH = 180; +#define ENTRY_SERIALIZED_LENGTH 180 + typedef struct HistoryEntry { unsigned char bytes[ENTRY_SERIALIZED_LENGTH]; } HistoryEntry;