diff options
author | Armin Rigo <arigo@tunes.org> | 2017-01-23 10:12:58 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2017-01-23 10:12:58 +0100 |
commit | a4a555495357afdeacb4837d947add4ff56d0d76 (patch) | |
tree | 9e38da380c627238716c08b08d14c641d5e7e415 | |
parent | ac5e396f1fb685a09e6f4e72b7fb5276a1344847 (diff) | |
download | cffi-a4a555495357afdeacb4837d947add4ff56d0d76.tar.gz |
Change the Windows-friendly version to be both Windows- and
POSIX-friendly (previously it *only* compiled on Windows)
-rw-r--r-- | doc/source/embedding.rst | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/doc/source/embedding.rst b/doc/source/embedding.rst index 1eab5e3..04fdac0 100644 --- a/doc/source/embedding.rst +++ b/doc/source/embedding.rst @@ -52,13 +52,25 @@ here this slightly expanded example: /* file plugin.h, Windows-friendly version */ typedef struct { int x, y; } point_t; - /* When including this file from ffibuilder.set_source(), - this macro is defined to __declspec(dllexport). When - including this file directly from your C program, we - define it to __declspec(dllimport) instead. */ + /* When including this file from ffibuilder.set_source(), the + following macro is defined to '__declspec(dllexport)'. When + including this file directly from your C program, we define + it to 'extern __declspec(dllimport)' instead. + + With non-MSVC compilers we simply define it to 'extern'. + (The 'extern' is needed for sharing global variables; + functions would be fine without it. The macros always + include 'extern': you must not repeat it when using the + macros later.) + */ #ifndef CFFI_DLLEXPORT - # define CFFI_DLLEXPORT __declspec(dllimport) + # if defined(_MSC_VER) + # define CFFI_DLLEXPORT extern __declspec(dllimport) + # else + # define CFFI_DLLEXPORT extern + # endif #endif + CFFI_DLLEXPORT int do_stuff(point_t *); .. code-block:: python |