summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-11-25 15:26:52 +0100
committerGravatar Nikias Bassen2026-11-25 15:26:52 +0100
commitd767ca577ad4bc365570a7ef079c8d9a8ab03baa (patch)
tree2543ee5254ed6063ce18feb154ca81816215e15a
parent2529f28bc25b678ba7d952543cdfed5d77eb9800 (diff)
downloadlibirecovery-d767ca577ad4bc365570a7ef079c8d9a8ab03baa.tar.gz
libirecovery-d767ca577ad4bc365570a7ef079c8d9a8ab03baa.tar.bz2
Windows: Don't use dllimport; only apply dllexport to DLL objectsHEADmaster
Public headers declared the API macro as __declspec(dllimport) on Windows unless *_STATIC was defined. That made consumers reference __imp_<symbol>, which only exists in the DLL import library, so linking against the static library failed unless the consumer also defined *_STATIC. All exported symbols are functions, so dllimport is not needed: calls to plain symbols link against both the static library and the import library (via its thunks). Drop it from the public headers. On the library side, apply __declspec(dllexport) only when libtool defines DLL_EXPORT, i.e. when compiling the objects for the DLL. This keeps export directives out of the objects that go into the static library when both are built.
-rw-r--r--include/libirecovery.h8
-rw-r--r--src/devicedb.c6
-rw-r--r--src/libirecovery.c6
3 files changed, 11 insertions, 9 deletions
diff --git a/include/libirecovery.h b/include/libirecovery.h
index 1db3785..e700ecc 100644
--- a/include/libirecovery.h
+++ b/include/libirecovery.h
@@ -28,13 +28,7 @@ extern "C" {
#include <stdint.h>
#ifndef IRECV_API
- #ifdef IRECV_STATIC
- #define IRECV_API
- #elif defined(_WIN32)
- #define IRECV_API __declspec(dllimport)
- #else
- #define IRECV_API
- #endif
+ #define IRECV_API
#endif
enum irecv_mode {
diff --git a/src/devicedb.c b/src/devicedb.c
index 36936c4..15c1112 100644
--- a/src/devicedb.c
+++ b/src/devicedb.c
@@ -51,7 +51,11 @@
#ifdef IRECV_STATIC
#define IRECV_API
#elif defined(_WIN32)
- #define IRECV_API __declspec( dllexport )
+ #ifdef DLL_EXPORT
+ #define IRECV_API __declspec( dllexport )
+ #else
+ #define IRECV_API
+ #endif
#else
#if __GNUC__ >= 4
#define IRECV_API __attribute__((visibility("default")))
diff --git a/src/libirecovery.c b/src/libirecovery.c
index afb9a88..406fb1a 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -61,7 +61,11 @@
#ifdef IRECV_STATIC
#define IRECV_API
#elif defined(_WIN32)
- #define IRECV_API __declspec( dllexport )
+ #ifdef DLL_EXPORT
+ #define IRECV_API __declspec( dllexport )
+ #else
+ #define IRECV_API
+ #endif
#else
#if __GNUC__ >= 4
#define IRECV_API __attribute__((visibility("default")))