summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2013-01-02 08:48:01 -0500
committerAnthony Green <green@moxielogic.com>2013-01-02 08:48:01 -0500
commited7a59c3ff7c84bd95c374a5aff21599f705e6dc (patch)
treecffeba1338cfb69a114b188c3225ce319eb6b6b1 /include
parentccee09a4ff843b11c7d8b6819776f57d187305c7 (diff)
downloadlibffi-ed7a59c3ff7c84bd95c374a5aff21599f705e6dc.tar.gz
Windows symbol export fix. Move to GCC.
Diffstat (limited to 'include')
-rw-r--r--include/ffi.h.in40
1 files changed, 27 insertions, 13 deletions
diff --git a/include/ffi.h.in b/include/ffi.h.in
index 84017f1..4f3b3de 100644
--- a/include/ffi.h.in
+++ b/include/ffi.h.in
@@ -166,22 +166,36 @@ typedef struct _ffi_type
#error "long size not supported"
#endif
+/* Need minimal decorations for DLLs to works on Windows. */
+/* GCC has autoimport and autoexport. Rely on Libtool to */
+/* help MSVC export from a DLL, but always declare data */
+/* to be imported for MSVC clients. This costs an extra */
+/* indirection for MSVC clients using the static version */
+/* of the library, but don't worry about that. Besides, */
+/* as a workaround, they can define FFI_BUILDING if they */
+/* *know* they are going to link with the static library. */
+#if defined _MSC_VER && !defined FFI_BUILDING
+#define FFI_EXTERN extern __declspec(dllimport)
+#else
+#define FFI_EXTERN extern
+#endif
+
/* These are defined in types.c */
-extern ffi_type ffi_type_void;
-extern ffi_type ffi_type_uint8;
-extern ffi_type ffi_type_sint8;
-extern ffi_type ffi_type_uint16;
-extern ffi_type ffi_type_sint16;
-extern ffi_type ffi_type_uint32;
-extern ffi_type ffi_type_sint32;
-extern ffi_type ffi_type_uint64;
-extern ffi_type ffi_type_sint64;
-extern ffi_type ffi_type_float;
-extern ffi_type ffi_type_double;
-extern ffi_type ffi_type_pointer;
+FFI_EXTERN ffi_type ffi_type_void;
+FFI_EXTERN ffi_type ffi_type_uint8;
+FFI_EXTERN ffi_type ffi_type_sint8;
+FFI_EXTERN ffi_type ffi_type_uint16;
+FFI_EXTERN ffi_type ffi_type_sint16;
+FFI_EXTERN ffi_type ffi_type_uint32;
+FFI_EXTERN ffi_type ffi_type_sint32;
+FFI_EXTERN ffi_type ffi_type_uint64;
+FFI_EXTERN ffi_type ffi_type_sint64;
+FFI_EXTERN ffi_type ffi_type_float;
+FFI_EXTERN ffi_type ffi_type_double;
+FFI_EXTERN ffi_type ffi_type_pointer;
#if @HAVE_LONG_DOUBLE@
-extern ffi_type ffi_type_longdouble;
+FFI_EXTERN ffi_type ffi_type_longdouble;
#else
#define ffi_type_longdouble ffi_type_double
#endif