CFFI_DLLEXPORT for MinGW on Windows

Issue #323 resolved
Melven Roehrig-Zoellner
created an issue

I was trying to build a DLL on Windows using the mingw-w64 compiler with code generated by CFFIs "emit_c_code".

Unfortunately the desired functions are not correctly "exported" in the DLL.

The MinGW compilers support __declspec(dllexport), so to fix this, I replaced

#if defined(_MSC_VER)
#  define CFFI_DLLEXPORT  __declspec(dllexport)
#elif defined(__GNUC__)
#  define CFFI_DLLEXPORT  __attribute__((visibility("default")))
#else
#  define CFFI_DLLEXPORT  /* nothing */
#endif

by

#if defined(_MSC_VER) || defined(_WIN32)
#  define CFFI_DLLEXPORT  __declspec(dllexport)
#elif defined(__GNUC__)
#  define CFFI_DLLEXPORT  __attribute__((visibility("default")))
#else
#  define CFFI_DLLEXPORT  /* nothing */
#endif

Not sure if this is the best preprocessor define to check, though.

The corresponding code seems to get copied from _embedding.h to the generated source file...

Comments (2)

  1. Log in to comment