diff options
author | Armin Rigo <arigo@tunes.org> | 2016-01-12 18:19:38 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2016-01-12 18:19:38 +0100 |
commit | 3d61fb1c89b5899acbba2ff9eb35a1a0fb0cac3f (patch) | |
tree | e9ad0a7879f9c46c0ee70a09837b35b51ac4c291 /testing | |
parent | 01c657dc137a097af648bc1fc4943864c4fb77ca (diff) | |
download | cffi-3d61fb1c89b5899acbba2ff9eb35a1a0fb0cac3f.tar.gz |
use declspec(dllimport/dllexport) on windows
Diffstat (limited to 'testing')
-rw-r--r-- | testing/embedding/add_recursive-test.c | 10 | ||||
-rw-r--r-- | testing/embedding/add_recursive.py | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/testing/embedding/add_recursive-test.c b/testing/embedding/add_recursive-test.c index 900da3e..cd29b79 100644 --- a/testing/embedding/add_recursive-test.c +++ b/testing/embedding/add_recursive-test.c @@ -1,7 +1,13 @@ #include <stdio.h> -extern int add_rec(int, int); -extern int (*my_callback)(int); +#ifdef _MSC_VER +# define DLLIMPORT __declspec(dllimport) +#else +# define DLLIMPORT extern +#endif + +DLLIMPORT int add_rec(int, int); +DLLIMPORT int (*my_callback)(int); static int some_callback(int x) { diff --git a/testing/embedding/add_recursive.py b/testing/embedding/add_recursive.py index d3b9c4d..9fa463d 100644 --- a/testing/embedding/add_recursive.py +++ b/testing/embedding/add_recursive.py @@ -24,7 +24,9 @@ ffi.embedding_init_code(r""" """) ffi.set_source("_add_recursive_cffi", """ -int (*my_callback)(int); +/* use CFFI_DLLEXPORT: on windows, it expands to __declspec(dllexport), + which is needed to export a variable from a dll */ +CFFI_DLLEXPORT int (*my_callback)(int); """) fn = ffi.compile(verbose=True) |