@@ -151,15 +151,29 @@ typedef int (*secp256k1_nonce_function)(
151151# define SECP256K1_API extern __declspec (dllimport)
152152# endif
153153#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")))
154174#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
175+ /* Fall back to standard C's extern. */
176+ # define SECP256K1_API extern
163177#endif
164178
165179/* Warning attributes
0 commit comments