diff options
author | Peter Rosin <peda@lysator.liu.se> | 2012-03-30 08:14:08 -0400 |
---|---|---|
committer | Anthony Green <green@moxielogic.com> | 2012-03-30 08:14:08 -0400 |
commit | 0a1ab12a8d15caa894116a82249551f23ef65612 (patch) | |
tree | 5be1ec4d91302d76b931bd5fce4d10e37e163b8e /include | |
parent | e1539266e6c6dde3c99832323586f33f977d1dc0 (diff) | |
download | libffi-0a1ab12a8d15caa894116a82249551f23ef65612.tar.gz |
Various MSVC-related changes.
Diffstat (limited to 'include')
-rw-r--r-- | include/ffi.h.in | 40 |
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 |