summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-11-25 15:20:38 +0100
committerGravatar Nikias Bassen2026-11-25 15:20:38 +0100
commit5aa836683822355ba6260a4ce88d5209762161a8 (patch)
tree441dabfc0ddc325c7091d2d3b28a2f9223e2ed6d
parentb3f14c22dbb29056c0d3c37bb9b2401ffdb7bc8f (diff)
downloadlibplist-5aa836683822355ba6260a4ce88d5209762161a8.tar.gz
libplist-5aa836683822355ba6260a4ce88d5209762161a8.tar.bz2
Windows: Don't use dllimport; only apply dllexport to DLL objects
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/plist/plist.h8
-rw-r--r--src/plist.h6
2 files changed, 6 insertions, 8 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index 0938525..975836f 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -76,13 +76,7 @@ extern "C"
/*}}}*/
#ifndef PLIST_API
- #ifdef LIBPLIST_STATIC
- #define PLIST_API
- #elif defined(_WIN32)
- #define PLIST_API __declspec(dllimport)
- #else
- #define PLIST_API
- #endif
+ #define PLIST_API
#endif
#include <sys/types.h>
diff --git a/src/plist.h b/src/plist.h
index 7228696..5b50192 100644
--- a/src/plist.h
+++ b/src/plist.h
@@ -40,7 +40,11 @@
#ifdef LIBPLIST_STATIC
#define PLIST_API
#elif defined(_WIN32)
- #define PLIST_API __declspec( dllexport )
+ #ifdef DLL_EXPORT
+ #define PLIST_API __declspec( dllexport )
+ #else
+ #define PLIST_API
+ #endif
#else
#if __GNUC__ >= 4
#define PLIST_API __attribute__((visibility("default")))