Skip to content

Commit 447334c

Browse files
include: Avoid visibility("default") on Windows
Fixes #1421.
1 parent 1988855 commit 447334c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

include/secp256k1.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ typedef int (*secp256k1_nonce_function)(
147147
* 1. If using Libtool, it defines DLL_EXPORT automatically.
148148
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
149149
# 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
150159
# endif
151160
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
152161
* library on Windows. */
@@ -156,11 +165,12 @@ typedef int (*secp256k1_nonce_function)(
156165
# endif
157166
#endif
158167
#ifndef SECP256K1_API
168+
/* All cases not captured by the Windows-specific logic. */
159169
# 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. */
161171
# define SECP256K1_API extern __attribute__ ((visibility ("default")))
162172
# else
163-
/* All cases not captured above. */
173+
/* Fall back to standard C's extern. */
164174
# define SECP256K1_API extern
165175
# endif
166176
#endif

0 commit comments

Comments
 (0)