Skip to content

Commit 57b520d

Browse files
build: Add SECP256K1_NO_VISIBILITY_ATTRIBUTES
1 parent 60c6bd8 commit 57b520d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/secp256k1.h

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

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

0 commit comments

Comments
 (0)