@@ -151,15 +151,30 @@ typedef int (*secp256k1_nonce_function)(
151
151
# define SECP256K1_API extern __declspec (dllimport)
152
152
# endif
153
153
#endif
154
+ #if !defined(SECP256K1_API ) \
155
+ && defined(__GNUC__ ) && (__GNUC__ >= 4 ) && defined(SECP256K1_BUILD ) \
156
+ && defined(SECP256K1_FORCE_HIDDEN_VISIBILITY )
157
+ /* Building libsecp256k1 using GCC or compatible on non-Windows, and hidden
158
+ * visibility is requested explicitly.
159
+ *
160
+ * Forcing hidden visibility can be useful, e.g., when building a static
161
+ * library which is linked into a shared library, and the latter should not
162
+ * reexport the libsecp256k1 API. Since this will create an unusable shared
163
+ * library, SECP256K1_FORCE_HIDDEN_VISIBILITY should only be used when building
164
+ * a static library. (You want to ./configure with --disable-shared if using
165
+ * Autotools.)
166
+ *
167
+ * While visibility is a concept that applies only to shared libraries, setting
168
+ * visibility will still make a difference when building a static library: the
169
+ * visibility settings will be stored in the static library, solely for the
170
+ * potential case that the static library will be linked into a shared library.
171
+ * In that case, the stored visibility settings will resurface and be honored
172
+ * for the shared library. */
173
+ # define SECP256K1_API extern __attribute__ ((visibility ("hidden")))
174
+ #endif
154
175
#ifndef SECP256K1_API
155
- /* All cases not captured by the Windows-specific logic. */
156
- # if defined(__GNUC__ ) && (__GNUC__ >= 4 ) && defined(SECP256K1_BUILD )
157
- /* Building libsecp256k1 using GCC or compatible. */
158
- # define SECP256K1_API extern
159
- # else
160
- /* Fall back to standard C's extern. */
161
- # define SECP256K1_API extern
162
- # endif
176
+ /* Fall back to standard C's extern. */
177
+ # define SECP256K1_API extern
163
178
#endif
164
179
165
180
/* Warning attributes
0 commit comments