Auto merge of #4527 - dannywillems:librustzcash/c-header-compatibility, r=str4d

librustzcash: make the header C compatible

The `librustzcash.h` file is compatible with both languages. However, only C++ is supported at the moment. By relying on the preprocessor to include or not the `extern "C"` piece, the interface becomes compatible with both.
This commit is contained in:
Homu 2020-05-27 21:23:08 +00:00
commit 8c778c9c0d
1 changed files with 11 additions and 1 deletions

View File

@ -3,7 +3,13 @@
#include <stdint.h>
const int ENTRY_SERIALIZED_LENGTH = 180;
#ifndef __cplusplus
#include <assert.h>
#include <stdalign.h>
#endif
#define ENTRY_SERIALIZED_LENGTH 180
typedef struct HistoryEntry {
unsigned char bytes[ENTRY_SERIALIZED_LENGTH];
} HistoryEntry;
@ -12,7 +18,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 +351,8 @@ extern "C" {
const unsigned char *n_ptr,
unsigned char *h_ret
);
#ifdef __cplusplus
}
#endif
#endif // LIBRUSTZCASH_INCLUDE_H_