Skip to content

Commit fb5a833

Browse files
build: Add SECP256K1_NO_VISIBILITY_ATTRIBUTES
1 parent ec4f00f commit fb5a833

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/secp256k1.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ typedef int (*secp256k1_nonce_function)(
121121
#endif
122122

123123
/* Symbol visibility. */
124+
#if !defined(SECP256K1_API) && defined(SECP256K1_NO_VISIBILITY_ATTRIBUTES)
125+
/* The user has requested that we don't specify visibility attributes.
126+
*
127+
* Since all our non-API declarations use the static qualifier, this means
128+
* that the user can use -fvisibility=<value> to set the visibility of the
129+
* API symbols. For instance, -fvisibility=hidden can be useful *even for
130+
* the API symbols*, e.g., when building a static library which is linked
131+
* into a shared library, and the latter should not re-export the
132+
* libsecp256k1 API.
133+
*
134+
* While visibility is a concept that applies only to shared libraries,
135+
* setting visibility will still make a difference when building a static
136+
* library: the visibility settings will be stored in the static library,
137+
* solely for the potential case that the static library will be linked into
138+
* a shared library. In that case, the stored visibility settings will
139+
* resurface and be honored for the shared library. */
140+
# define SECP256K1_API extern
141+
#endif
124142
#if !defined(SECP256K1_API)
125143
# if defined(SECP256K1_BUILD)
126144
/* On Windows, assume a shared library only if explicitly requested.

0 commit comments

Comments
 (0)