From 8debc94f84233e6d99e93fd3f9a4139569e4557d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:43:26 +0100 Subject: [PATCH] build: Use `SECP256K1_STATICLIB` macro instead of warning suppressions This change allows the user to define the `SECP256K1_STATICLIB` macro instead of ignoring MSVC linker warnings LNK4217 and LNK4286. --- Makefile.am | 6 +++--- examples/CMakeLists.txt | 2 +- include/secp256k1.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 51484a0eec..12a5aed667 100644 --- a/Makefile.am +++ b/Makefile.am @@ -153,7 +153,7 @@ endif if USE_EXAMPLES noinst_PROGRAMS += ecdsa_example ecdsa_example_SOURCES = examples/ecdsa.c -ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include +ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATICLIB ecdsa_example_LDADD = libsecp256k1.la ecdsa_example_LDFLAGS = -static if BUILD_WINDOWS @@ -163,7 +163,7 @@ TESTS += ecdsa_example if ENABLE_MODULE_ECDH noinst_PROGRAMS += ecdh_example ecdh_example_SOURCES = examples/ecdh.c -ecdh_example_CPPFLAGS = -I$(top_srcdir)/include +ecdh_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATICLIB ecdh_example_LDADD = libsecp256k1.la ecdh_example_LDFLAGS = -static if BUILD_WINDOWS @@ -174,7 +174,7 @@ endif if ENABLE_MODULE_SCHNORRSIG noinst_PROGRAMS += schnorr_example schnorr_example_SOURCES = examples/schnorr.c -schnorr_example_CPPFLAGS = -I$(top_srcdir)/include +schnorr_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATICLIB schnorr_example_LDADD = libsecp256k1.la schnorr_example_LDFLAGS = -static if BUILD_WINDOWS diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e095b7f84f..a314c1787c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,7 +7,7 @@ target_link_libraries(example INTERFACE $<$:bcrypt> ) if(NOT BUILD_SHARED_LIBS AND MSVC) - target_link_options(example INTERFACE /IGNORE:4217) + target_compile_definitions(example INTERFACE SECP256K1_STATICLIB) endif() add_executable(ecdsa_example ecdsa.c) diff --git a/include/secp256k1.h b/include/secp256k1.h index a7a2be7a3a..927625ffad 100644 --- a/include/secp256k1.h +++ b/include/secp256k1.h @@ -140,7 +140,7 @@ typedef int (*secp256k1_nonce_function)( # define SECP256K1_API __declspec (dllexport) # define SECP256K1_API_VAR extern __declspec (dllexport) # endif -# elif defined _MSC_VER +# elif defined(_MSC_VER) && !defined(SECP256K1_STATICLIB) # define SECP256K1_API # define SECP256K1_API_VAR extern __declspec (dllimport) # elif defined DLL_EXPORT