@@ -147,6 +147,15 @@ typedef int (*secp256k1_nonce_function)(
147
147
* 1. If using Libtool, it defines DLL_EXPORT automatically.
148
148
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
149
149
# define SECP256K1_API extern __declspec (dllexport)
150
+ # else
151
+ /* Building libsecp256k1 as a static library on Windows.
152
+ * No declspec is needed, and so we would want the non-Windows-specific
153
+ * logic below take care of this case. However, this may result in setting
154
+ * __attribute__ ((visibility("default"))), which is supposed to be a noop
155
+ * on Windows but may trigger warnings when compiling with -flto due to a
156
+ * bug in GCC, see
157
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478 . */
158
+ # define SECP256K1_API extern
150
159
# endif
151
160
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
152
161
* library on Windows. */
@@ -156,11 +165,12 @@ typedef int (*secp256k1_nonce_function)(
156
165
# endif
157
166
#endif
158
167
#ifndef SECP256K1_API
168
+ /* All cases not captured by the Windows-specific logic. */
159
169
# if defined(__GNUC__ ) && (__GNUC__ >= 4 ) && defined(SECP256K1_BUILD )
160
- /* Building libsecp256k1 on non-Windows using GCC or compatible. */
170
+ /* Building libsecp256k1 using GCC or compatible. */
161
171
# define SECP256K1_API extern __attribute__ ((visibility ("default")))
162
172
# else
163
- /* All cases not captured above . */
173
+ /* Fall back to standard C's extern . */
164
174
# define SECP256K1_API extern
165
175
# endif
166
176
#endif
0 commit comments