From ce7923874f3f51dd87f396e0be655e2b25ad4629 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 2 Jul 2025 11:56:40 +0200 Subject: [PATCH] build: Add SECP256K1_NO_API_VISIBILITY_ATTRIBUTES --- include/secp256k1.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/secp256k1.h b/include/secp256k1.h index d67d9642..f55a6ab9 100644 --- a/include/secp256k1.h +++ b/include/secp256k1.h @@ -121,6 +121,25 @@ typedef int (*secp256k1_nonce_function)( #endif /* Symbol visibility. */ +#if !defined(SECP256K1_API) && defined(SECP256K1_NO_API_VISIBILITY_ATTRIBUTES) + /* The user has requested that we don't specify visibility attributes in + * the public API. + * + * Since all our non-API declarations use the static qualifier, this means + * that the user can use -fvisibility= to set the visibility of the + * API symbols. For instance, -fvisibility=hidden can be useful *even for + * the API symbols*, e.g., when building a static library which is linked + * into a shared library, and the latter should not re-export the + * libsecp256k1 API. + * + * While visibility is a concept that applies only to shared libraries, + * setting visibility will still make a difference when building a static + * library: the visibility settings will be stored in the static library, + * solely for the potential case that the static library will be linked into + * a shared library. In that case, the stored visibility settings will + * resurface and be honored for the shared library. */ +# define SECP256K1_API extern +#endif #if !defined(SECP256K1_API) # if defined(SECP256K1_BUILD) /* On Windows, assume a shared library only if explicitly requested.