From 8d80f2f1d6fd29d53559a3be1b6919c98e424491 Mon Sep 17 00:00:00 2001 From: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com> Date: Tue, 13 May 2025 17:11:08 +0000 Subject: [PATCH] Fix secp256k1 compilation on Windows. --- secp256k1/src/scratch.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/secp256k1/src/scratch.h b/secp256k1/src/scratch.h index fef377a..1cc6334 100644 --- a/secp256k1/src/scratch.h +++ b/secp256k1/src/scratch.h @@ -20,20 +20,28 @@ typedef struct secp256k1_scratch_space_struct { const secp256k1_callback* error_callback; } secp256k1_scratch; -static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t max_size); +#if defined(_WIN32) || defined(_WIN64) + #define S +#else + #define S static +#endif + +S secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t max_size); -static void secp256k1_scratch_destroy(secp256k1_scratch* scratch); +S void secp256k1_scratch_destroy(secp256k1_scratch* scratch); /** Attempts to allocate a new stack frame with `n` available bytes. Returns 1 on success, 0 on failure */ -static int secp256k1_scratch_allocate_frame(secp256k1_scratch* scratch, size_t n, size_t objects); +S int secp256k1_scratch_allocate_frame(secp256k1_scratch* scratch, size_t n, size_t objects); /** Deallocates a stack frame */ -static void secp256k1_scratch_deallocate_frame(secp256k1_scratch* scratch); +S void secp256k1_scratch_deallocate_frame(secp256k1_scratch* scratch); /** Returns the maximum allocation the scratch space will allow */ -static size_t secp256k1_scratch_max_allocation(const secp256k1_scratch* scratch, size_t n_objects); +S size_t secp256k1_scratch_max_allocation(const secp256k1_scratch* scratch, size_t n_objects); /** Returns a pointer into the most recently allocated frame, or NULL if there is insufficient available space */ -static void *secp256k1_scratch_alloc(secp256k1_scratch* scratch, size_t n); +S void *secp256k1_scratch_alloc(secp256k1_scratch* scratch, size_t n); + +#undef S #endif